diff --git a/rust/fastsim-core/src/cycle.rs b/rust/fastsim-core/src/cycle.rs index 0d8bf0bd..f487422e 100644 --- a/rust/fastsim-core/src/cycle.rs +++ b/rust/fastsim-core/src/cycle.rs @@ -649,10 +649,7 @@ impl SerdeAPI for RustCycle { match format.trim_start_matches('.').to_lowercase().as_str() { "yaml" | "yml" => serde_yaml::to_writer(wtr, self)?, "json" => serde_json::to_writer(wtr, self)?, - "toml" => { - let toml_string = self.to_toml()?; - wtr.write_all(toml_string.as_bytes())?; - }, + "toml" => wtr.write_all(self.to_toml()?.as_bytes())?, #[cfg(feature = "bincode")] "bin" => bincode::serialize_into(wtr, self)?, "csv" => { @@ -709,7 +706,11 @@ impl SerdeAPI for RustCycle { ) } - fn from_reader(mut rdr: R, format: &str, skip_init: bool) -> anyhow::Result { + fn from_reader( + mut rdr: R, + format: &str, + skip_init: bool, + ) -> anyhow::Result { let mut deserialized = match format.trim_start_matches('.').to_lowercase().as_str() { "yaml" | "yml" => serde_yaml::from_reader(rdr)?, "json" => serde_json::from_reader(rdr)?, @@ -717,7 +718,7 @@ impl SerdeAPI for RustCycle { let mut buf = String::new(); rdr.read_to_string(&mut buf)?; Self::from_toml(buf, skip_init)? - }, + } #[cfg(feature = "bincode")] "bin" => bincode::deserialize_from(rdr)?, "csv" => { @@ -823,7 +824,11 @@ impl RustCycle { } /// Load cycle from CSV string - pub fn from_csv_str>(csv_str: S, name: String, skip_init: bool) -> anyhow::Result { + pub fn from_csv_str>( + csv_str: S, + name: String, + skip_init: bool, + ) -> anyhow::Result { let mut cyc = Self::from_str(csv_str, "csv", skip_init)?; cyc.name = name; Ok(cyc) diff --git a/rust/fastsim-core/src/traits.rs b/rust/fastsim-core/src/traits.rs index 8362f7c6..5d5c6c0b 100644 --- a/rust/fastsim-core/src/traits.rs +++ b/rust/fastsim-core/src/traits.rs @@ -52,10 +52,7 @@ pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { match format.trim_start_matches('.').to_lowercase().as_str() { "yaml" | "yml" => serde_yaml::to_writer(wtr, self)?, "json" => serde_json::to_writer(wtr, self)?, - "toml" => { - let toml_string = self.to_toml()?; - wtr.write_all(toml_string.as_bytes())?; - }, + "toml" => wtr.write_all(self.to_toml()?.as_bytes())?, #[cfg(feature = "bincode")] "bin" => bincode::serialize_into(wtr, self)?, _ => bail!( @@ -135,7 +132,11 @@ pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { /// * `rdr` - The reader from which to read object data /// * `format` - The source format, any of those listed in [`ACCEPTED_BYTE_FORMATS`](`SerdeAPI::ACCEPTED_BYTE_FORMATS`) /// - fn from_reader(mut rdr: R, format: &str, skip_init: bool) -> anyhow::Result { + fn from_reader( + mut rdr: R, + format: &str, + skip_init: bool, + ) -> anyhow::Result { let mut deserialized: Self = match format.trim_start_matches('.').to_lowercase().as_str() { "yaml" | "yml" => serde_yaml::from_reader(rdr)?, "json" => serde_json::from_reader(rdr)?, @@ -143,7 +144,7 @@ pub trait SerdeAPI: Serialize + for<'a> Deserialize<'a> { let mut buf = String::new(); rdr.read_to_string(&mut buf)?; Self::from_toml(buf, skip_init)? - }, + } #[cfg(feature = "bincode")] "bin" => bincode::deserialize_from(rdr)?, _ => bail!(