error.rs
This file
Path
src/hyperfine/error.rs
53 lines · 1.3 KiB · Rust
Last changed by
convert to rust edition 2018Andrii Radykbefore adoption2d0b048
History of this fileTake it
1use std::error::Error;2use std::fmt;3use std::num;45#[derive(Debug)]6pub enum ParameterScanError {7 ParseIntError(num::ParseIntError),8 EmptyRange,9 TooLarge,10}1112impl From<num::ParseIntError> for ParameterScanError {13 fn from(e: num::ParseIntError) -> ParameterScanError {14 ParameterScanError::ParseIntError(e)15 }16}1718impl fmt::Display for ParameterScanError {19 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {20 write!(f, "{}", self.description())21 }22}2324impl Error for ParameterScanError {25 fn description(&self) -> &str {26 match *self {27 ParameterScanError::ParseIntError(ref e) => e.description(),28 ParameterScanError::EmptyRange => "Empty parameter range",29 ParameterScanError::TooLarge => "Parameter range is too large",30 }31 }32}3334#[derive(Debug)]35pub enum OptionsError {36 RunsBelowTwo,37 EmptyRunsRange,38}3940impl fmt::Display for OptionsError {41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {42 write!(f, "{}", self.description())43 }44}4546impl Error for OptionsError {47 fn description(&self) -> &str {48 match *self {49 OptionsError::EmptyRunsRange => "Empty runs range",50 OptionsError::RunsBelowTwo => "Number of runs below two",51 }52 }53}