Skip to content

Commit

Permalink
refactor: Optimize code based on cargo clippy suggestions
Browse files Browse the repository at this point in the history
Signed-off-by: one230six <[email protected]>
  • Loading branch information
one230six committed Mar 13, 2024
1 parent 5493cf5 commit 810cd7b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl<'a> Command<'a> {
let parameters =
self.get_unused_parameters()
.fold(String::new(), |output, (parameter, value)| {
output + &format!("{} = {}, ", parameter, value.to_string())
output + &format!("{} = {}, ", parameter, value)
});
let parameters = parameters.trim_end_matches(", ");
let parameters = if parameters.is_empty() {
Expand Down
10 changes: 6 additions & 4 deletions src/parameter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use std::fmt::Display;
use crate::util::number::Number;

pub mod range_step;
Expand All @@ -9,12 +10,13 @@ pub enum ParameterValue {
Numeric(Number),
}

impl ToString for ParameterValue {
fn to_string(&self) -> String {
match self {
impl Display for ParameterValue {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
ParameterValue::Text(ref value) => value.clone(),
ParameterValue::Numeric(value) => value.to_string(),
}
};
write!(f, "{}", str)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/util/min_max.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::iter::Iterator;

/// A max function for f64's without NaNs
pub fn max(vals: &[f64]) -> f64 {
Expand Down

0 comments on commit 810cd7b

Please sign in to comment.