Add a from impl for ParseIntError
As is customary add a `From` impl for the `ParseIntError` and use `?`. While this does not make much difference it saves devs wondering why there is a `From` impl for one of the variants and not the other.
This commit is contained in:
parent
2130150df6
commit
fb81bff61f
|
@ -87,7 +87,7 @@ impl FromStr for WitnessVersion {
|
||||||
type Err = FromStrError;
|
type Err = FromStrError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||||
let version: u8 = crate::parse::int(s).map_err(FromStrError::Unparsable)?;
|
let version: u8 = crate::parse::int(s)?;
|
||||||
Ok(WitnessVersion::try_from(version)?)
|
Ok(WitnessVersion::try_from(version)?)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,6 +198,10 @@ impl std::error::Error for FromStrError {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl From<ParseIntError> for FromStrError {
|
||||||
|
fn from(e: ParseIntError) -> Self { Self::Unparsable(e) }
|
||||||
|
}
|
||||||
|
|
||||||
impl From<TryFromError> for FromStrError {
|
impl From<TryFromError> for FromStrError {
|
||||||
fn from(e: TryFromError) -> Self { Self::Invalid(e) }
|
fn from(e: TryFromError) -> Self { Self::Invalid(e) }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue