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
Provenance
- Commit
9a064b7- Tree
2061620- Author
Andrii Radyk <ander.ender@gmail.com>- Committer
David Peter <sharkdp@users.noreply.github.com>- Parent
6dd32ad
2 files changed+18 added−26 removed
modified:src/hyperfine/error.rs+14 added-21 removed
25 unmodified lines26 }27 28 impl fmt::Display for ParameterScanError {29 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {30- write!(f, "{}", self.description())31- }32-}33-34-impl 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 }45 46+impl Error for ParameterScanError {}47+48 #[derive(Debug)]49 pub enum OptionsError {50 RunsBelowTwo,51 EmptyRunsRange,52 }53 54 impl fmt::Display for OptionsError {55 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {59- write!(f, "{}", self.description())60- }61-}62-63-impl 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 }62+63+impl Error for OptionsError {}modified:src/main.rs+4 added-5 removed
1 use std::cmp;2 use std::env;3-use std::error::Error;3 use std::io;4 5 use atty::Stream;6 use clap::ArgMatches;49 unmodified lines56 let commands = build_commands(&matches);57 58 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 };62 63 match res {64 Ok(timing_results) => {6 unmodified lines71 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 }82 83 /// Build the HyperfineOptions that correspond to the given ArgMatches120 unmodified lines204 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