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:
<!-- 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<()> {
let f = File::open("hello.txt");
@ -143,15 +143,14 @@ the example like this:
<!-- I'll ghost everything except `?` in the libreoffice file /Carol -->
```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