mirror of
https://github.com/sharkdp/hyperfine.git
synced 2024-09-11 14:07:02 +03:00
refactor: Optimize code based on cargo clippy suggestions
Signed-off-by: one230six <723682061@qq.com> refactor: Optimize code based on cargo clippy suggestions Signed-off-by: one230six <723682061@qq.com>
This commit is contained in:
parent
865b496098
commit
c0921351e7
@ -59,11 +59,11 @@ impl<'a> Command<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_name_with_unused_parameters(&self) -> String {
|
pub fn get_name_with_unused_parameters(&self) -> String {
|
||||||
let parameters =
|
let parameters = self
|
||||||
self.get_unused_parameters()
|
.get_unused_parameters()
|
||||||
.fold(String::new(), |output, (parameter, value)| {
|
.fold(String::new(), |output, (parameter, value)| {
|
||||||
output + &format!("{} = {}, ", parameter, value.to_string())
|
output + &format!("{} = {}, ", parameter, value)
|
||||||
});
|
});
|
||||||
let parameters = parameters.trim_end_matches(", ");
|
let parameters = parameters.trim_end_matches(", ");
|
||||||
let parameters = if parameters.is_empty() {
|
let parameters = if parameters.is_empty() {
|
||||||
"".into()
|
"".into()
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
use crate::util::number::Number;
|
use crate::util::number::Number;
|
||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
pub mod range_step;
|
pub mod range_step;
|
||||||
pub mod tokenize;
|
pub mod tokenize;
|
||||||
@ -9,12 +10,13 @@ pub enum ParameterValue {
|
|||||||
Numeric(Number),
|
Numeric(Number),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToString for ParameterValue {
|
impl Display for ParameterValue {
|
||||||
fn to_string(&self) -> String {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
match self {
|
let str = match self {
|
||||||
ParameterValue::Text(ref value) => value.clone(),
|
ParameterValue::Text(ref value) => value.clone(),
|
||||||
ParameterValue::Numeric(value) => value.to_string(),
|
ParameterValue::Numeric(value) => value.to_string(),
|
||||||
}
|
};
|
||||||
|
write!(f, "{}", str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
use std::iter::Iterator;
|
|
||||||
|
|
||||||
/// A max function for f64's without NaNs
|
/// A max function for f64's without NaNs
|
||||||
pub fn max(vals: &[f64]) -> f64 {
|
pub fn max(vals: &[f64]) -> f64 {
|
||||||
*vals
|
*vals
|
||||||
|
Loading…
Reference in New Issue
Block a user