Fix remaining clippy warnings
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by David Peter · committed by David Peter · parent 85730b3 · Browse files · 7 files·+44 added−24 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+44 added−24 removed
- other:+44 added−24 removed
Provenance
- Commit
068bebb- Tree
7acea79- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
85730b3
7 files changed+44 added−24 removed
modified:src/hyperfine/export/csv.rs+1 added-2 removed
30 unmodified lines31 writer.write_record(headers)?;32 }33 34 for res in results {35- let mut fields = Vec::new();36- fields.push(Cow::Borrowed(res.command.as_bytes()));35+ let mut fields = vec![Cow::Borrowed(res.command.as_bytes())];36 for f in &[37 res.mean, res.stddev, res.median, res.user, res.system, res.min, res.max,38 ] {39 fields.push(Cow::Owned(f.to_string().into_bytes()))68 unmodified linesmodified:src/hyperfine/timer/unix_timer.rs+1 added
48 unmodified lines49 };50 51 const MICROSEC_PER_SEC: i64 = 1000 * 1000;52 53+ #[allow(clippy::useless_conversion)]54 CPUTimes {55 user_usec: i64::from(result.ru_utime.tv_sec) * MICROSEC_PER_SEC56 + i64::from(result.ru_utime.tv_usec),57 system_usec: i64::from(result.ru_stime.tv_sec) * MICROSEC_PER_SEC39 unmodified linesmodified:src/hyperfine/benchmark.rs+27 added-10 removed
145 unmodified lines146 times_system.push(r.time_system);147 }148 }149 150- if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }150+ if let Some(bar) = progress_bar.as_ref() {151+ bar.inc(1)152+ }153 }154 153- if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }155+ if let Some(bar) = progress_bar.as_ref() {156+ bar.finish_and_clear()157+ }158 159 Ok(TimingResult {160 time_real: mean(×_real),161 time_user: mean(×_user),117 unmodified lines279 options.show_output,280 options.failure_action,281 None,282 )?;279- if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }283+ if let Some(bar) = progress_bar.as_ref() {284+ bar.inc(1)285+ }286 }281- if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }287+ if let Some(bar) = progress_bar.as_ref() {288+ bar.finish_and_clear()289+ }290 }291 292 // Set up progress bar (and spinner for initial measurement)293 let progress_bar = if options.output_style != OutputStyleOption::Disabled {44 unmodified lines338 339 all_succeeded = all_succeeded && success;340 341 // Re-configure the progress bar334- if let Some(bar) = progress_bar.as_ref() { bar.set_length(count) }335- if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }342+ if let Some(bar) = progress_bar.as_ref() {343+ bar.set_length(count)344+ }345+ if let Some(bar) = progress_bar.as_ref() {346+ bar.inc(1)347+ }348 349 // Gather statistics350 for _ in 0..count_remaining {351 run_preparation_command(&options.shell, &prepare_cmd, options.show_output)?;2 unmodified lines354 let mean = format_duration(mean(×_real), options.time_unit);355 format!("Current estimate: {}", mean.to_string().green())356 };357 346- if let Some(bar) = progress_bar347- .as_ref() { bar.set_message(msg.to_owned()) }358+ if let Some(bar) = progress_bar.as_ref() {359+ bar.set_message(msg.to_owned())360+ }361 362 let (res, status) = time_shell_command(363 &options.shell,364 cmd,9 unmodified lines374 exit_codes.push(extract_exit_code(status));375 376 all_succeeded = all_succeeded && success;377 365- if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }378+ if let Some(bar) = progress_bar.as_ref() {379+ bar.inc(1)380+ }381 }382 368- if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }383+ if let Some(bar) = progress_bar.as_ref() {384+ bar.finish_and_clear()385+ }386 387 // Compute statistical quantities388 let t_num = times_real.len();389 let t_mean = mean(×_real);95 unmodified linesmodified:src/hyperfine/format.rs+2 added-3 removed
1 unmodified line2 3 /// Format the given duration as a string. The output-unit can be enforced by setting `unit` to4 /// `Some(target_unit)`. If `unit` is `None`, it will be determined automatically.5 pub fn format_duration(duration: Second, unit: Option<Unit>) -> String {6- match format_duration_unit(duration, unit) {7- (duration_fmt, _) => duration_fmt,8- }6+ let (duration_fmt, _) = format_duration_unit(duration, unit);7+ duration_fmt8 }9 10 /// Like `format_duration`, but returns the target unit as well.11 pub fn format_duration_unit(duration: Second, unit: Option<Unit>) -> (String, Unit) {54 unmodified linesmodified:src/hyperfine/parameter_range.rs+2 added-1 removed
116 unmodified lines117 for value in param_range {118 for cmd in &command_strings {119 let name = command_names120 .get(i)121- .or_else(|| command_names.get(0)).copied();121+ .or_else(|| command_names.get(0))122+ .copied();123 commands.push(Command::new_parametrized(124 name,125 cmd,126 vec![(param_name, ParameterValue::Numeric(value.into()))],188 unmodified linesmodified:src/hyperfine/types.rs+7 added-6 removed
28 unmodified lines29 }30 }31 }32 33-impl Into<NumericType> for i32 {34- fn into(self) -> NumericType {35- NumericType::Int(self)33+impl From<i32> for NumericType {34+ fn from(x: i32) -> NumericType {35+ NumericType::Int(x)36 }37 }38 39-impl Into<NumericType> for Decimal {40- fn into(self) -> NumericType {41- NumericType::Decimal(self)39+impl From<Decimal> for NumericType {40+ fn from(x: Decimal) -> NumericType {41+ NumericType::Decimal(x)42 }43 }44 45 impl TryFrom<NumericType> for usize {278 unmodified lines324 }325 326 impl BenchmarkResult {327 /// Create a new entry with the given values.328+ #[allow(clippy::too_many_arguments)]329 pub fn new(330 command: String,331 mean: Second,332 stddev: Second,24 unmodified linesmodified:src/main.rs+4 added-2 removed
95 unmodified lines96 let param_to_u64 = |param| {97 matches98 .value_of(param)99 .map(|n| {100+ n.parse::<u64>()100- u64::from_str_radix(n, 10).map_err(|e| OptionsError::NumericParsingError(param, e))101+ .map_err(|e| OptionsError::NumericParsingError(param, e))102 })103 .transpose()104 };105 164 unmodified lines270 let mut index = vec![0usize; dimensions.len()];271 'outer: loop {272 let name = command_names273 .get(i)273- .or_else(|| command_names.get(0)).copied();274+ .or_else(|| command_names.get(0))275+ .copied();276 i += 1;277 278 let (command_index, params_indices) = index.split_first().unwrap();279 let parameters = param_names_and_values128 unmodified lines