Skip to content

Commit 69447cc

Browse files
Merge pull request #246 from cmleinz/master
Fix clippy lints
2 parents 175f6c1 + 8ada017 commit 69447cc

File tree

4 files changed

+26
-18
lines changed

4 files changed

+26
-18
lines changed

src/cosmic/cosm.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl FrameTree {
7777
/// Seek an ephemeris from its celestial name (e.g. Earth Moon Barycenter)
7878
fn frame_seek_by_name(
7979
name: &str,
80-
cur_path: &mut [usize],
80+
cur_path: &[usize],
8181
f: &FrameTree,
8282
) -> Result<Vec<usize>, NyxError> {
8383
if f.name == name {
@@ -91,7 +91,7 @@ impl FrameTree {
9191
for (cno, child) in f.children.iter().enumerate() {
9292
let mut this_path = cur_path.to_owned();
9393
this_path.push(cno);
94-
let child_attempt = Self::frame_seek_by_name(name, &mut this_path, child);
94+
let child_attempt = Self::frame_seek_by_name(name, &this_path, child);
9595
if let Ok(found_path) = child_attempt {
9696
return Ok(found_path);
9797
}
@@ -230,15 +230,15 @@ impl Cosm {
230230
// Return an empty vector (but OK because we're asking for the root)
231231
Ok(Vec::new())
232232
} else {
233-
let mut path = Vec::new();
234-
Self::frame_find_path(name, &mut path, &self.frame_root)
233+
let path = Vec::new();
234+
Self::frame_find_path(name, &path, &self.frame_root)
235235
}
236236
}
237237

238238
/// Seek a frame from its orientation name
239239
fn frame_find_path(
240240
frame_name: &str,
241-
cur_path: &mut [usize],
241+
cur_path: &[usize],
242242
f: &FrameTree,
243243
) -> Result<Vec<usize>, NyxError> {
244244
if f.name == frame_name {
@@ -250,8 +250,8 @@ impl Cosm {
250250
))
251251
} else {
252252
for child in &f.children {
253-
let mut this_path = cur_path.to_owned();
254-
let child_attempt = Self::frame_find_path(frame_name, &mut this_path, child);
253+
let this_path = cur_path.to_owned();
254+
let child_attempt = Self::frame_find_path(frame_name, &this_path, child);
255255
if let Ok(found_path) = child_attempt {
256256
return Ok(found_path);
257257
}
@@ -565,10 +565,10 @@ impl Cosm {
565565
// Return an empty vector (but OK because we're asking for the root)
566566
Ok(self.frame_root.frame)
567567
} else {
568-
let mut path = Vec::new();
568+
let path = Vec::new();
569569
Ok(self.frame_from_frame_path(&FrameTree::frame_seek_by_name(
570570
&name,
571-
&mut path,
571+
&path,
572572
&self.frame_root,
573573
)?))
574574
}

src/cosmic/mod.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use crate::linalg::{DefaultAllocator, DimName, OMatrix, OVector};
2525
use crate::md::StateParameter;
2626
use crate::time::{Duration, Epoch, Unit};
2727
use hifitime::SECONDS_PER_DAY;
28-
use std::fmt;
28+
use std::fmt::{self, Write};
2929
use std::fs::File;
3030
use std::io::Read;
3131
#[cfg(not(target_arch = "wasm32"))]
@@ -207,7 +207,10 @@ impl Xb {
207207
}
208208
for pos in path {
209209
if root.children.get(*pos).is_none() {
210-
let hpath: String = path.iter().map(|p| format!("{p}")).collect::<String>();
210+
let hpath = path.iter().fold(String::new(), |mut output, p| {
211+
let _ = write!(output, "{p}");
212+
output
213+
});
211214
return Err(NyxError::ObjectNotFound(hpath, self.ephemeris_get_names()));
212215
}
213216
}
@@ -231,7 +234,7 @@ impl Xb {
231234
/// Seek an ephemeris from its celestial name (e.g. Earth Moon Barycenter)
232235
fn ephemeris_seek_by_name(
233236
name: &str,
234-
cur_path: &mut [usize],
237+
cur_path: &[usize],
235238
e: &Ephemeris,
236239
) -> Result<Vec<usize>, NyxError> {
237240
if e.name == name {
@@ -245,7 +248,7 @@ impl Xb {
245248
for (cno, child) in e.children.iter().enumerate() {
246249
let mut this_path = cur_path.to_owned();
247250
this_path.push(cno);
248-
let child_attempt = Self::ephemeris_seek_by_name(name, &mut this_path, child);
251+
let child_attempt = Self::ephemeris_seek_by_name(name, &this_path, child);
249252
if let Ok(found_path) = child_attempt {
250253
return Ok(found_path);
251254
}
@@ -270,8 +273,8 @@ impl Xb {
270273
// Return an empty vector (but OK because we're asking for the root)
271274
Ok(Vec::new())
272275
} else {
273-
let mut path = Vec::new();
274-
Self::ephemeris_seek_by_name(&name, &mut path, root)
276+
let path = Vec::new();
277+
Self::ephemeris_seek_by_name(&name, &path, root)
275278
}
276279
}
277280
}

src/dynamics/spacecraft.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub use crate::md::prelude::SolarPressure;
3030
use crate::md::prelude::{Harmonics, PointMasses};
3131
use crate::State;
3232

33-
use std::fmt;
33+
use std::fmt::{self, Write};
3434
use std::sync::Arc;
3535

3636
use crate::cosmic::Cosm;
@@ -243,7 +243,12 @@ impl fmt::Display for SpacecraftDynamics {
243243
let force_models: String = if self.force_models.is_empty() {
244244
"No force models;".to_string()
245245
} else {
246-
self.force_models.iter().map(|x| format!("{x}; ")).collect()
246+
self.force_models
247+
.iter()
248+
.fold(String::new(), |mut output, x| {
249+
let _ = write!(output, "{x}; ");
250+
output
251+
})
247252
};
248253
write!(
249254
f,

src/md/trajectory/orbit_traj.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ impl Traj<Orbit> {
238238
// Grab the path here before we move stuff.
239239
let path_buf = cfg.actual_path(path);
240240

241-
let metadata = cfg.metadata.unwrap_or(HashMap::new());
241+
let metadata = cfg.metadata.unwrap_or_default();
242242

243243
let file = File::create(&path_buf)
244244
.map_err(|e| NyxError::CCSDS(format!("File creation error: {e}")))?;

0 commit comments

Comments
 (0)