Skip to content

Commit 82b79aa

Browse files
authored
Merge pull request #1259 from mfurak/format-errors5
style: format errors5 & errors6 with rustfmt
2 parents 8b0507c + 152193b commit 82b79aa

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

exercises/error_handling/errors5.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// For now, think of the `Box<dyn ...>` type as an "I want anything that does ???" type, which, given
88
// Rust's usual standards for runtime safety, should strike you as somewhat lenient!
99

10-
// In short, this particular use case for boxes is for when you want to own a value and you care only that it is a
10+
// In short, this particular use case for boxes is for when you want to own a value and you care only that it is a
1111
// type which implements a particular trait. To do so, The Box is declared as of type Box<dyn Trait> where Trait is the trait
1212
// the compiler looks for on any value used in that context. For this exercise, that context is the potential errors
1313
// which can be returned in a Result.
@@ -46,7 +46,7 @@ impl PositiveNonzeroInteger {
4646
match value {
4747
x if x < 0 => Err(CreationError::Negative),
4848
x if x == 0 => Err(CreationError::Zero),
49-
x => Ok(PositiveNonzeroInteger(x as u64))
49+
x => Ok(PositiveNonzeroInteger(x as u64)),
5050
}
5151
}
5252
}

exercises/error_handling/errors6.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use std::num::ParseIntError;
1616
#[derive(PartialEq, Debug)]
1717
enum ParsePosNonzeroError {
1818
Creation(CreationError),
19-
ParseInt(ParseIntError)
19+
ParseInt(ParseIntError),
2020
}
2121

2222
impl ParsePosNonzeroError {
@@ -27,14 +27,11 @@ impl ParsePosNonzeroError {
2727
// fn from_parseint...
2828
}
2929

30-
fn parse_pos_nonzero(s: &str)
31-
-> Result<PositiveNonzeroInteger, ParsePosNonzeroError>
32-
{
30+
fn parse_pos_nonzero(s: &str) -> Result<PositiveNonzeroInteger, ParsePosNonzeroError> {
3331
// TODO: change this to return an appropriate error instead of panicking
3432
// when `parse()` returns an error.
3533
let x: i64 = s.parse().unwrap();
36-
PositiveNonzeroInteger::new(x)
37-
.map_err(ParsePosNonzeroError::from_creation)
34+
PositiveNonzeroInteger::new(x).map_err(ParsePosNonzeroError::from_creation)
3835
}
3936

4037
// Don't change anything below this line.
@@ -53,7 +50,7 @@ impl PositiveNonzeroInteger {
5350
match value {
5451
x if x < 0 => Err(CreationError::Negative),
5552
x if x == 0 => Err(CreationError::Zero),
56-
x => Ok(PositiveNonzeroInteger(x as u64))
53+
x => Ok(PositiveNonzeroInteger(x as u64)),
5754
}
5855
}
5956
}

0 commit comments

Comments
 (0)