style: format errors6 with rustfmt

This commit is contained in:
mfurak 2022-11-06 20:42:17 +01:00
parent d01ce8304e
commit 152193b459

View File

@ -16,7 +16,7 @@ use std::num::ParseIntError;
#[derive(PartialEq, Debug)] #[derive(PartialEq, Debug)]
enum ParsePosNonzeroError { enum ParsePosNonzeroError {
Creation(CreationError), Creation(CreationError),
ParseInt(ParseIntError) ParseInt(ParseIntError),
} }
impl ParsePosNonzeroError { impl ParsePosNonzeroError {
@ -27,14 +27,11 @@ impl ParsePosNonzeroError {
// fn from_parseint... // fn from_parseint...
} }
fn parse_pos_nonzero(s: &str) fn parse_pos_nonzero(s: &str) -> Result<PositiveNonzeroInteger, ParsePosNonzeroError> {
-> Result<PositiveNonzeroInteger, ParsePosNonzeroError>
{
// TODO: change this to return an appropriate error instead of panicking // TODO: change this to return an appropriate error instead of panicking
// when `parse()` returns an error. // when `parse()` returns an error.
let x: i64 = s.parse().unwrap(); let x: i64 = s.parse().unwrap();
PositiveNonzeroInteger::new(x) PositiveNonzeroInteger::new(x).map_err(ParsePosNonzeroError::from_creation)
.map_err(ParsePosNonzeroError::from_creation)
} }
// Don't change anything below this line. // Don't change anything below this line.
@ -53,7 +50,7 @@ impl PositiveNonzeroInteger {
match value { match value {
x if x < 0 => Err(CreationError::Negative), x if x < 0 => Err(CreationError::Negative),
x if x == 0 => Err(CreationError::Zero), x if x == 0 => Err(CreationError::Zero),
x => Ok(PositiveNonzeroInteger(x as u64)) x => Ok(PositiveNonzeroInteger(x as u64)),
} }
} }
} }