Skip to content
Myr

refactor: Optimize code based on cargo clippy suggestions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Signed-off-by: one230six <723682061@qq.com> refactor: Optimize code based on cargo clippy suggestions

authored by one230six · committed by David Peter · parent 865b496 · Browse files · 3 files+11 added−11 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Trailers

  • Signed-off-by: one230six <723682061@qq.com>

Diff stats

3 files+11 added−11 removed

  • other:+11 added−11 removed

3 files+11 added−11 removed

modified:src/parameter/mod.rs+6 added-4 removed
1use crate::util::number::Number;2use std::fmt::Display;34pub mod range_step;5pub mod tokenize;6
2 unmodified lines
9 Text(String),10 Numeric(Number),11}1212impl ToString for ParameterValue {13 fn to_string(&self) -> String {14 match self {13impl Display for ParameterValue {14 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {15 let str = match self {16 ParameterValue::Text(ref value) => value.clone(),17 ParameterValue::Numeric(value) => value.to_string(),17 }18 };19 write!(f, "{}", str)20 }21}2223pub type ParameterNameAndValue<'a> = (&'a str, ParameterValue);
modified:src/util/min_max.rs-2 removed
1use std::iter::Iterator;21/// A max function for f64's without NaNs2pub fn max(vals: &[f64]) -> f64 {3 *vals4 .iter()
24 unmodified lines
modified:src/command.rs+5 added-5 removed
57 unmodified lines
58 )59 }6061 pub fn get_name_with_unused_parameters(&self) -> String {62 let parameters =63 self.get_unused_parameters()64 .fold(String::new(), |output, (parameter, value)| {65 output + &format!("{} = {}, ", parameter, value.to_string())66 });62 let parameters = self63 .get_unused_parameters()64 .fold(String::new(), |output, (parameter, value)| {65 output + &format!("{} = {}, ", parameter, value)66 });67 let parameters = parameters.trim_end_matches(", ");68 let parameters = if parameters.is_empty() {69 "".into()70 } else {
495 unmodified lines