Auto-fix 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 489e30c · Browse files · 6 files·+17 added−20 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
6 files+17 added−20 removed
- other:+17 added−20 removed
Provenance
- Commit
85730b3- Tree
0826a32- Author
David Peter <mail@david-peter.de>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
489e30c
6 files changed+17 added−20 removed
modified:src/hyperfine/export/mod.rs+1 added-1 removed
73 unmodified lines74 75 /// Write the given results to all Exporters contained within this manager76 pub fn write_results(&self, results: &[BenchmarkResult], unit: Option<Unit>) -> Result<()> {77 for e in &self.exporters {78- let file_content = e.exporter.serialize(&results, unit)?;78+ let file_content = e.exporter.serialize(results, unit)?;79 write_to_file(&e.filename, &file_content)?;80 }81 Ok(())82 }7 unmodified linesmodified:src/hyperfine/benchmark.rs+10 added-11 removed
145 unmodified lines146 times_system.push(r.time_system);147 }148 }149 150- progress_bar.as_ref().map(|bar| bar.inc(1));150+ if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }151 }152 153- progress_bar.as_ref().map(|bar| bar.finish_and_clear());153+ if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }154 155 Ok(TimingResult {156 time_real: mean(×_real),157 time_user: mean(×_user),117 unmodified lines275 options.show_output,276 options.failure_action,277 None,278 )?;279- progress_bar.as_ref().map(|bar| bar.inc(1));279+ if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }280 }281- progress_bar.as_ref().map(|bar| bar.finish_and_clear());281+ if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }282 }283 284 // Set up progress bar (and spinner for initial measurement)285 let progress_bar = if options.output_style != OutputStyleOption::Disabled {44 unmodified lines330 331 all_succeeded = all_succeeded && success;332 333 // Re-configure the progress bar334- progress_bar.as_ref().map(|bar| bar.set_length(count));335- progress_bar.as_ref().map(|bar| bar.inc(1));334+ if let Some(bar) = progress_bar.as_ref() { bar.set_length(count) }335+ if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }336 337 // Gather statistics338 for _ in 0..count_remaining {339 run_preparation_command(&options.shell, &prepare_cmd, options.show_output)?;2 unmodified lines342 let mean = format_duration(mean(×_real), options.time_unit);343 format!("Current estimate: {}", mean.to_string().green())344 };345 346- progress_bar347- .as_ref()348- .map(|bar| bar.set_message(msg.to_owned()));346+ if let Some(bar) = progress_bar347+ .as_ref() { bar.set_message(msg.to_owned()) }348 349 let (res, status) = time_shell_command(350 &options.shell,351 cmd,9 unmodified lines361 exit_codes.push(extract_exit_code(status));362 363 all_succeeded = all_succeeded && success;364 366- progress_bar.as_ref().map(|bar| bar.inc(1));365+ if let Some(bar) = progress_bar.as_ref() { bar.inc(1) }366 }367 369- progress_bar.as_ref().map(|bar| bar.finish_and_clear());368+ if let Some(bar) = progress_bar.as_ref() { bar.finish_and_clear() }369 370 // Compute statistical quantities371 let t_num = times_real.len();372 let t_mean = mean(×_real);95 unmodified linesmodified:src/hyperfine/internal.rs+1 added-1 removed
103 unmodified lines104 if results.len() < 2 {105 return;106 }107 108- if let Some(mut annotated_results) = compute_relative_speed(&results) {108+ if let Some(mut annotated_results) = compute_relative_speed(results) {109 annotated_results.sort_by(|l, r| compare_mean_time(l.result, r.result));110 111 let fastest = &annotated_results[0];112 let others = &annotated_results[1..];142 unmodified linesmodified:src/hyperfine/parameter_range.rs+1 added-2 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))122- .map(|s| *s);121+ .or_else(|| command_names.get(0)).copied();122 commands.push(Command::new_parametrized(123 name,124 cmd,125 vec![(param_name, ParameterValue::Numeric(value.into()))],188 unmodified linesmodified:src/hyperfine/types.rs+1 added-1 removed
136 unmodified lines137 // should not ever run 'echo baz baz'. See `test_get_shell_command_nonoverlapping`.138 'outer: while let Some(head) = remaining.chars().next() {139 for (k, v) in &replacements {140 if remaining.starts_with(k.as_str()) {141- result.push_str(&v);141+ result.push_str(v);142 remaining = &remaining[k.len()..];143 continue 'outer;144 }145 }210 unmodified linesmodified:src/main.rs+3 added-4 removed
76 unmodified lines77 Err(ref e) => error(&e.to_string()),78 };79 80 let res = match options {81- Ok(ref opts) => run(&commands, &opts, &export_manager),81+ Ok(ref opts) => run(&commands, opts, &export_manager),82 Err(ref e) => error(&e.to_string()),83 };84 85 match res {183 unmodified lines269 let mut index = vec![0usize; dimensions.len()];270 'outer: loop {271 let name = command_names272 .get(i)273- .or_else(|| command_names.get(0))274- .map(|s| *s);273+ .or_else(|| command_names.get(0)).copied();274 i += 1;275 276 let (command_index, params_indices) = index.split_first().unwrap();277 let parameters = param_names_and_values29 unmodified lines307 308 let command_list = command_strings.collect::<Vec<&str>>();309 let mut commands = Vec::with_capacity(command_list.len());310 for (i, s) in command_list.iter().enumerate() {312- commands.push(Command::new(command_names.get(i).copied(), &s));311+ commands.push(Command::new(command_names.get(i).copied(), s));312 }313 commands314 }315 }90 unmodified lines