Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy lints #246

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/cosmic/cosm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl FrameTree {
/// Seek an ephemeris from its celestial name (e.g. Earth Moon Barycenter)
fn frame_seek_by_name(
name: &str,
cur_path: &mut [usize],
cur_path: &[usize],
f: &FrameTree,
) -> Result<Vec<usize>, NyxError> {
if f.name == name {
Expand All @@ -91,7 +91,7 @@ impl FrameTree {
for (cno, child) in f.children.iter().enumerate() {
let mut this_path = cur_path.to_owned();
this_path.push(cno);
let child_attempt = Self::frame_seek_by_name(name, &mut this_path, child);
let child_attempt = Self::frame_seek_by_name(name, &this_path, child);
if let Ok(found_path) = child_attempt {
return Ok(found_path);
}
Expand Down Expand Up @@ -230,15 +230,15 @@ impl Cosm {
// Return an empty vector (but OK because we're asking for the root)
Ok(Vec::new())
} else {
let mut path = Vec::new();
Self::frame_find_path(name, &mut path, &self.frame_root)
let path = Vec::new();
Self::frame_find_path(name, &path, &self.frame_root)
}
}

/// Seek a frame from its orientation name
fn frame_find_path(
frame_name: &str,
cur_path: &mut [usize],
cur_path: &[usize],
f: &FrameTree,
) -> Result<Vec<usize>, NyxError> {
if f.name == frame_name {
Expand All @@ -250,8 +250,8 @@ impl Cosm {
))
} else {
for child in &f.children {
let mut this_path = cur_path.to_owned();
let child_attempt = Self::frame_find_path(frame_name, &mut this_path, child);
let this_path = cur_path.to_owned();
let child_attempt = Self::frame_find_path(frame_name, &this_path, child);
if let Ok(found_path) = child_attempt {
return Ok(found_path);
}
Expand Down Expand Up @@ -565,10 +565,10 @@ impl Cosm {
// Return an empty vector (but OK because we're asking for the root)
Ok(self.frame_root.frame)
} else {
let mut path = Vec::new();
let path = Vec::new();
Ok(self.frame_from_frame_path(&FrameTree::frame_seek_by_name(
&name,
&mut path,
&path,
&self.frame_root,
)?))
}
Expand Down
15 changes: 9 additions & 6 deletions src/cosmic/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ use crate::linalg::{DefaultAllocator, DimName, OMatrix, OVector};
use crate::md::StateParameter;
use crate::time::{Duration, Epoch, Unit};
use hifitime::SECONDS_PER_DAY;
use std::fmt;
use std::fmt::{self, Write};
use std::fs::File;
use std::io::Read;
#[cfg(not(target_arch = "wasm32"))]
Expand Down Expand Up @@ -207,7 +207,10 @@ impl Xb {
}
for pos in path {
if root.children.get(*pos).is_none() {
let hpath: String = path.iter().map(|p| format!("{p}")).collect::<String>();
let hpath = path.iter().fold(String::new(), |mut output, p| {
let _ = write!(output, "{p}");
output
});
return Err(NyxError::ObjectNotFound(hpath, self.ephemeris_get_names()));
}
}
Expand All @@ -231,7 +234,7 @@ impl Xb {
/// Seek an ephemeris from its celestial name (e.g. Earth Moon Barycenter)
fn ephemeris_seek_by_name(
name: &str,
cur_path: &mut [usize],
cur_path: &[usize],
e: &Ephemeris,
) -> Result<Vec<usize>, NyxError> {
if e.name == name {
Expand All @@ -245,7 +248,7 @@ impl Xb {
for (cno, child) in e.children.iter().enumerate() {
let mut this_path = cur_path.to_owned();
this_path.push(cno);
let child_attempt = Self::ephemeris_seek_by_name(name, &mut this_path, child);
let child_attempt = Self::ephemeris_seek_by_name(name, &this_path, child);
if let Ok(found_path) = child_attempt {
return Ok(found_path);
}
Expand All @@ -270,8 +273,8 @@ impl Xb {
// Return an empty vector (but OK because we're asking for the root)
Ok(Vec::new())
} else {
let mut path = Vec::new();
Self::ephemeris_seek_by_name(&name, &mut path, root)
let path = Vec::new();
Self::ephemeris_seek_by_name(&name, &path, root)
}
}
}
Expand Down
9 changes: 7 additions & 2 deletions src/dynamics/spacecraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub use crate::md::prelude::SolarPressure;
use crate::md::prelude::{Harmonics, PointMasses};
use crate::State;

use std::fmt;
use std::fmt::{self, Write};
use std::sync::Arc;

use crate::cosmic::Cosm;
Expand Down Expand Up @@ -243,7 +243,12 @@ impl fmt::Display for SpacecraftDynamics {
let force_models: String = if self.force_models.is_empty() {
"No force models;".to_string()
} else {
self.force_models.iter().map(|x| format!("{x}; ")).collect()
self.force_models
.iter()
.fold(String::new(), |mut output, x| {
let _ = write!(output, "{x}; ");
output
})
};
write!(
f,
Expand Down
2 changes: 1 addition & 1 deletion src/md/trajectory/orbit_traj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ impl Traj<Orbit> {
// Grab the path here before we move stuff.
let path_buf = cfg.actual_path(path);

let metadata = cfg.metadata.unwrap_or(HashMap::new());
let metadata = cfg.metadata.unwrap_or_default();

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