Skip to content
Myr

remove deprecated Error::description

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

authored by Andrii Radyk · committed by David Peter · parent 6dd32ad · Browse files · 2 files+18 added−26 removed
This commit

State

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

Diff stats

2 files+18 added−26 removed

  • other:+18 added−26 removed

2 files+18 added−26 removed

modified:src/hyperfine/error.rs+14 added-21 removed
25 unmodified lines
26}2728impl fmt::Display for ParameterScanError {29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {30 write!(f, "{}", self.description())31 }32}3334impl Error for ParameterScanError {35 fn description(&self) -> &str {30 match *self {37 ParameterScanError::ParseIntError(ref e) => e.description(),38 ParameterScanError::ParseDecimalError(ref e) => e.description(),39 ParameterScanError::EmptyRange => "Empty parameter range",40 ParameterScanError::TooLarge => "Parameter range is too large",41 ParameterScanError::ZeroStep => "Zero is not a valid parameter step",42 ParameterScanError::StepRequired => {31 ParameterScanError::ParseIntError(ref e) => write!(f, "{}", e),32 ParameterScanError::ParseDecimalError(ref e) => write!(f, "{}", e),33 ParameterScanError::EmptyRange => write!(f, "Empty parameter range"),34 ParameterScanError::TooLarge => write!(f, "Parameter range is too large"),35 ParameterScanError::ZeroStep => write!(f, "Zero is not a valid parameter step"),36 ParameterScanError::StepRequired => write!(37 f,38 "A step size is required when the range bounds are \39 floating point numbers. The step size can be specified \40 with the '--parameter-step-size' parameter"46 }41 ),42 }43 }44}4546impl Error for ParameterScanError {}4748#[derive(Debug)]49pub enum OptionsError {50 RunsBelowTwo,51 EmptyRunsRange,52}5354impl fmt::Display for OptionsError {55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {59 write!(f, "{}", self.description())60 }61}6263impl Error for OptionsError {64 fn description(&self) -> &str {56 match *self {66 OptionsError::EmptyRunsRange => "Empty runs range",67 OptionsError::RunsBelowTwo => "Number of runs below two",57 OptionsError::EmptyRunsRange => write!(f, "Empty runs range"),58 OptionsError::RunsBelowTwo => write!(f, "Number of runs below two"),59 }60 }61}6263impl Error for OptionsError {}
modified:src/main.rs+4 added-5 removed
1use std::cmp;2use std::env;3use std::error::Error;3use std::io;45use atty::Stream;6use clap::ArgMatches;
49 unmodified lines
56 let commands = build_commands(&matches);5758 let res = match options {59 Ok(ref opts) => run(&commands, &opts),61 Err(ref e) => error(e.description()),60 Err(ref e) => error(&e.to_string()),61 };6263 match res {64 Ok(timing_results) => {
6 unmodified lines
71 let ans = export_manager.write_results(timing_results, options.time_unit);72 if let Err(e) = ans {73 error(&format!(74 "The following error occurred while exporting: {}",76 e.description()75 e76 ));77 }78 }80 Err(e) => error(e.description()),79 Err(e) => error(&e.to_string()),80 }81}8283/// Build the HyperfineOptions that correspond to the given ArgMatches
120 unmodified lines
204 if let Some(args) = matches.values_of("parameter-scan") {205 let step_size = matches.value_of("parameter-step-size");206 match get_parameterized_commands(command_strings, args, step_size) {207 Ok(commands) => commands,209 Err(e) => error(e.description()),208 Err(e) => error(&e.to_string()),209 }210 } else if let Some(mut args) = matches.values_of("parameter-list") {211 let param_name = args.next().unwrap();212 let param_list_str = args.next().unwrap();
21 unmodified lines