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

refactor: Optimize code based on cargo clippy suggestions #734

Merged
merged 1 commit into from
Mar 14, 2024
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
10 changes: 5 additions & 5 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ impl<'a> Command<'a> {
}

pub fn get_name_with_unused_parameters(&self) -> String {
let parameters =
self.get_unused_parameters()
.fold(String::new(), |output, (parameter, value)| {
output + &format!("{} = {}, ", parameter, value.to_string())
});
let parameters = self
.get_unused_parameters()
.fold(String::new(), |output, (parameter, value)| {
output + &format!("{} = {}, ", parameter, value)
});
let parameters = parameters.trim_end_matches(", ");
let parameters = if parameters.is_empty() {
"".into()
Expand Down
10 changes: 6 additions & 4 deletions src/parameter/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::util::number::Number;
use std::fmt::Display;

pub mod range_step;
pub mod tokenize;
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
2 changes: 0 additions & 2 deletions src/util/min_max.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use std::iter::Iterator;

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