Skip to content

Commit 0b2019f

Browse files
committed
rustfmt
1 parent 8599c64 commit 0b2019f

7 files changed

Lines changed: 31 additions & 37 deletions

File tree

src/codes_file/iterator.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,17 @@ impl<'ch, D: Debug> FallibleIterator for RefMessageIter<'ch, D> {
7272
///
7373
/// `ArcMessage` implements `Send + Sync` so it can be both moved to thread (for example, to read messages in parallel)
7474
/// or shared across threads (when wrapped in [`Arc`]).
75-
///
75+
///
7676
/// This structure implements [`FallibleIterator`] - see the documentation for information how that differs from a standard `Iter`.
7777
///
7878
/// Creating this iter does not require `CodesFile` to be mutable, because it takes ownership over the `CodesFile`.
7979
///
8080
/// If you don't need to share the message, use [`RefMessageIter`] to avoid the performance overhead of [`Arc`].
81-
///
81+
///
8282
/// If you want to modify the message, use [`try_clone()`](RefMessage::try_clone).
83-
///
83+
///
8484
/// ## Example
85-
///
85+
///
8686
/// See the second example in the main crate description for example usage of `ArcMessageIter`.
8787
#[derive(Debug)]
8888
pub struct ArcMessageIter<D: Debug> {
@@ -106,9 +106,9 @@ impl<D: Debug> FallibleIterator for ArcMessageIter<D> {
106106
///
107107
/// The method will return [`CodesInternal`](crate::errors::CodesInternal)
108108
/// when internal ecCodes function returns non-zero code.
109-
///
109+
///
110110
/// # Panics
111-
///
111+
///
112112
/// This method internally uses a Mutex to access `CodesFile`, which can panic when poisoned,
113113
/// but thers is no path in which you can get to the state of poisoned mutex, while still able to access this method.
114114
fn next(&mut self) -> Result<Option<Self::Item>, Self::Error> {

src/codes_message/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ use crate::{CodesFile, intermediate_bindings::codes_handle_delete};
4343
/// You can read a `Key` with static types using [`read_key()`](KeyRead::read_key()) or with [`DynamicKeyType`] using[`read_key_dynamic()`](CodesMessage::read_key_dynamic())
4444
/// To iterate over all key names use [`KeysIterator`](crate::KeysIterator). You can also modify the message using
4545
/// [`write_key_unchecked()`](KeyWrite::write_key_unchecked()) (only available for `BufMessage`).
46-
///
46+
///
4747
/// [`CodesNearest`](crate::CodesNearest) can be used to find nearest gridpoints for given coordinates in the `CodesMessage`.
48-
///
48+
///
4949
/// To write the message to file use [`write_to_file()`](CodesMessage::write_to_file).
5050
///
5151
/// If you are interested only in getting data values from the message you can use

src/intermediate_bindings/codes_set.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,8 @@ pub unsafe fn codes_set_long_array(
5353

5454
let length = values.len();
5555

56-
let error_code = eccodes_sys::codes_set_long_array(
57-
handle,
58-
key.as_ptr(),
59-
values.as_ptr().cast(),
60-
length,
61-
);
56+
let error_code =
57+
eccodes_sys::codes_set_long_array(handle, key.as_ptr(), values.as_ptr().cast(), length);
6258
error_code_to_result(error_code)?;
6359

6460
Ok(())

src/intermediate_bindings/mod.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ pub use codes_get::{
3030
codes_get_long_array, codes_get_message, codes_get_native_type, codes_get_size,
3131
codes_get_string,
3232
};
33-
pub use codes_handle::{
34-
codes_handle_clone, codes_handle_delete, codes_handle_new_from_file,
35-
};
33+
pub use codes_handle::{codes_handle_clone, codes_handle_delete, codes_handle_new_from_file};
3634
pub use codes_keys::{
3735
codes_keys_iterator_delete, codes_keys_iterator_get_name, codes_keys_iterator_new,
3836
codes_keys_iterator_next,

src/keys_iterator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ use crate::{
3333
/// # fn main() -> anyhow::Result<()> {
3434
/// let mut handle = CodesFile::new_from_file("./data/iceland.grib", ProductKind::GRIB)?;
3535
/// let mut current_message = handle.ref_message_iter().next()?.context("no message")?;
36-
///
36+
///
3737
/// let mut keys_iter = current_message.default_keys_iterator()?;
38-
///
38+
///
3939
/// while let Some(key_name) = keys_iter.next()? {
4040
/// println!("{key_name}");
4141
/// }

src/lib.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -178,26 +178,26 @@
178178
//! use anyhow::Context;
179179
//! use eccodes::{CodesFile, FallibleIterator, KeyRead, KeyWrite, ProductKind};
180180
//! use std::{collections::HashMap, fs::remove_file, path::Path};
181-
//!
181+
//!
182182
//! # fn main() -> anyhow::Result<()> {
183183
//! // Start by opening the file and creating CodesFile
184184
//! let file_path = Path::new("./data/iceland-levels.grib");
185185
//! let mut handle = CodesFile::new_from_file(file_path, ProductKind::GRIB)?;
186-
//!
186+
//!
187187
//! // To build the index we need to collect all messages
188188
//! let messages = handle.ref_message_iter().collect::<Vec<_>>()?;
189189
//! let mut msg_index = HashMap::new();
190190
//! msg_index.reserve(messages.len());
191-
//!
191+
//!
192192
//! // Now we can put the messages into a hashmap and index them by shortName and level
193193
//! for msg in messages.into_iter() {
194194
//! // all messages in this grib are on the same level type
195195
//! let short_name: String = msg.read_key("shortName")?;
196196
//! let level: i64 = msg.read_key("level")?;
197-
//!
197+
//!
198198
//! msg_index.insert((short_name, level), msg);
199199
//! }
200-
//!
200+
//!
201201
//! // Now we can get the values from messages we need
202202
//! let t_800: Vec<f64> = msg_index
203203
//! .get(&("t".to_string(), 800))
@@ -207,24 +207,24 @@
207207
//! .get(&("t".to_string(), 800))
208208
//! .context("message missing")?
209209
//! .read_key("values")?;
210-
//!
210+
//!
211211
//! // We will also clone t at 700hPa to edit it
212212
//! let mut t_850_msg = msg_index
213213
//! .get(&("t".to_string(), 700))
214214
//! .context("message missing")?
215215
//! .try_clone()?;
216-
//!
216+
//!
217217
//! // Compute temperature at 850hPa
218218
//! let t_850_values: Vec<f64> = t_800
219219
//! .iter()
220220
//! .zip(t_900.iter())
221221
//! .map(|t| (t.0 + t.1) / 2.0)
222222
//! .collect();
223-
//!
223+
//!
224224
//! // Edit appropriate keys in the cloned (editable) message
225225
//! t_850_msg.write_key_unchecked("level", 850)?;
226226
//! t_850_msg.write_key_unchecked("values", t_850_values.as_slice())?;
227-
//!
227+
//!
228228
//! // Save the message to a new file without appending
229229
//! t_850_msg.write_to_file(Path::new("iceland-850.grib"), false)?;
230230
//! # remove_file(Path::new("iceland-850.grib")).unwrap();
@@ -233,7 +233,7 @@
233233
//! ```
234234
//!
235235
//! ## Changes in version 0.14
236-
//!
236+
//!
237237
//! 1. `experimental_index` feature has been removed - users are encouraged to create their own indexes as shown above or use iterator filtering
238238
//! 2. `message_ndarray` feature has been renamed to `ndarray`
239239
//! 3. `CodesHandle` has been renamed to `CodesFile`
@@ -266,7 +266,7 @@ pub mod keys_iterator;
266266
mod pointer_guard;
267267

268268
pub use codes_file::{ArcMessageIter, CodesFile, ProductKind, RefMessageIter};
269-
pub use codes_message::{ArcMessage, BufMessage, KeyRead, KeyWrite, RefMessage, DynamicKeyType};
269+
pub use codes_message::{ArcMessage, BufMessage, DynamicKeyType, KeyRead, KeyWrite, RefMessage};
270270
pub use codes_nearest::{CodesNearest, NearestGridpoint};
271271
pub use errors::CodesError;
272272
pub use fallible_iterator::{FallibleIterator, IntoFallibleIterator};

tests/example.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use anyhow::Context;
22
use eccodes::{CodesFile, FallibleIterator, ProductKind};
33
fn main() -> anyhow::Result<()> {
4-
let mut handle = CodesFile::new_from_file("./data/iceland.grib", ProductKind::GRIB)?;
5-
let mut current_message = handle.ref_message_iter().next()?.context("no message")?;
4+
let mut handle = CodesFile::new_from_file("./data/iceland.grib", ProductKind::GRIB)?;
5+
let mut current_message = handle.ref_message_iter().next()?.context("no message")?;
66

7-
let mut keys_iter = current_message.default_keys_iterator()?;
7+
let mut keys_iter = current_message.default_keys_iterator()?;
88

9-
while let Some(key_name) = keys_iter.next()? {
10-
println!("{key_name}");
11-
}
12-
Ok(())
9+
while let Some(key_name) = keys_iter.next()? {
10+
println!("{key_name}");
11+
}
12+
Ok(())
1313
}

0 commit comments

Comments
 (0)