Skip to content

Commit

Permalink
fix(errorsn): Try harder to confine the user. (rust-lang#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
EvanCarroll authored and MendelMonteiro committed Jun 28, 2020
1 parent 9e78d61 commit efe4755
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions exercises/error_handling/errorsn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
// This is a bigger error exercise than the previous ones!
// You can do it! :)
//
// Edit the `read_and_validate` function so that it compiles and
// passes the tests... so many things could go wrong!
// Edit the `read_and_validate` function ONLY. Don't create any Errors
// that do not already exist.
//
// So many things could go wrong!
//
// - Reading from stdin could produce an io::Error
// - Parsing the input could produce a num::ParseIntError
Expand All @@ -28,6 +30,10 @@ fn read_and_validate(b: &mut dyn io::BufRead) -> Result<PositiveNonzeroInteger,
Ok(answer)
}

//
// Nothing below this needs to be modified
//

// This is a test helper function that turns a &str into a BufReader.
fn test_with_str(s: &str) -> Result<PositiveNonzeroInteger, Box<dyn error::Error>> {
let mut b = io::BufReader::new(s.as_bytes());
Expand Down

0 comments on commit efe4755

Please sign in to comment.