diff --git a/src/doc/trpl/error-handling.md b/src/doc/trpl/error-handling.md index 68671cef70740..52a4e7324ee56 100644 --- a/src/doc/trpl/error-handling.md +++ b/src/doc/trpl/error-handling.md @@ -1838,6 +1838,22 @@ impl<'a, 'b> From<&'b str> for Box impl From for Box ``` +Since `search` now returns a `Result`, `main` should use case analysis +when calling `search`: + +```rust,ignore +... +match search(&data_file, &city) { + Ok(pops) => { + for pop in pops { + println!("{}, {}: {:?}", pop.city, pop.country, pop.count); + } + } + Err(err) => println!("{}", err) +} +... +``` + Now that we've seen how to do proper error handling with `Box`, let's try a different approach with our own custom error type. But first, let's take a quick break from error handling and add support for reading from `stdin`.