Make these code examples build off each other

Yes, this means we can't test these, but imo this makes more sense.
This commit is contained in:
Carol (Nichols || Goulding) 2016-09-01 10:51:16 -04:00
parent 79bac99c21
commit b88aad0d98

View File

@ -121,9 +121,9 @@ you can return the error to the calling function. Within your function, that
would look like: would look like:
<!-- I'll ghost everything except `return Err(e)` in the libreoffice file /Carol --> <!-- I'll ghost everything except `return Err(e)` in the libreoffice file /Carol -->
```rust
use std::fs::File;
```rust,ignore
# use std::fs::File;
# fn foo() -> std::io::Result<()> { # fn foo() -> std::io::Result<()> {
let f = File::open("hello.txt"); let f = File::open("hello.txt");
@ -143,15 +143,14 @@ the example like this:
<!-- I'll ghost everything except `?` in the libreoffice file /Carol --> <!-- I'll ghost everything except `?` in the libreoffice file /Carol -->
```rust ```rust,ignore
#![feature(question_mark)] #![feature(question_mark)]
use std::fs::File; use std::fs::File;
# fn foo() -> std::io::Result<()> { fn main() {
let f = File::open("hello.txt")?; let f = File::open("hello.txt")?;
# Ok(()) }
# }
``` ```
The `?` operator at the end of the `open` call does the same thing as our The `?` operator at the end of the `open` call does the same thing as our