fix(errorsn): Try harder to confine the user. (#388)
This commit is contained in:
parent
1b4590b42b
commit
2b20c8a0f5
|
@ -2,8 +2,10 @@
|
||||||
// This is a bigger error exercise than the previous ones!
|
// This is a bigger error exercise than the previous ones!
|
||||||
// You can do it! :)
|
// You can do it! :)
|
||||||
//
|
//
|
||||||
// Edit the `read_and_validate` function so that it compiles and
|
// Edit the `read_and_validate` function ONLY. Don't create any Errors
|
||||||
// passes the tests... so many things could go wrong!
|
// that do not already exist.
|
||||||
|
//
|
||||||
|
// So many things could go wrong!
|
||||||
//
|
//
|
||||||
// - Reading from stdin could produce an io::Error
|
// - Reading from stdin could produce an io::Error
|
||||||
// - Parsing the input could produce a num::ParseIntError
|
// - Parsing the input could produce a num::ParseIntError
|
||||||
|
@ -30,6 +32,10 @@ fn read_and_validate(b: &mut dyn io::BufRead) -> Result<PositiveNonzeroInteger,
|
||||||
answer
|
answer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Nothing below this needs to be modified
|
||||||
|
//
|
||||||
|
|
||||||
// This is a test helper function that turns a &str into a BufReader.
|
// 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>> {
|
fn test_with_str(s: &str) -> Result<PositiveNonzeroInteger, Box<dyn error::Error>> {
|
||||||
let mut b = io::BufReader::new(s.as_bytes());
|
let mut b = io::BufReader::new(s.as_bytes());
|
||||||
|
|
Loading…
Reference in a new issue