From b88aad0d98f78edde78ecaab9d3f2a79df41e653 Mon Sep 17 00:00:00 2001 From: "Carol (Nichols || Goulding)" Date: Thu, 1 Sep 2016 10:51:16 -0400 Subject: [PATCH] Make these code examples build off each other Yes, this means we can't test these, but imo this makes more sense. --- src/ch09-02-recoverable-errors-with-result.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/ch09-02-recoverable-errors-with-result.md b/src/ch09-02-recoverable-errors-with-result.md index af221e39d..27e7b5ecb 100644 --- a/src/ch09-02-recoverable-errors-with-result.md +++ b/src/ch09-02-recoverable-errors-with-result.md @@ -121,9 +121,9 @@ you can return the error to the calling function. Within your function, that would look like: -```rust -use std::fs::File; +```rust,ignore +# use std::fs::File; # fn foo() -> std::io::Result<()> { let f = File::open("hello.txt"); @@ -143,15 +143,14 @@ the example like this: -```rust +```rust,ignore #![feature(question_mark)] use std::fs::File; -# fn foo() -> std::io::Result<()> { -let f = File::open("hello.txt")?; -# Ok(()) -# } +fn main() { + let f = File::open("hello.txt")?; +} ``` The `?` operator at the end of the `open` call does the same thing as our