Update book to

244f893ed7

Some changes have landed before we managed to extract things; this
updates things to be in line with those changes.
This commit is contained in:
steveklabnik 2017-03-20 11:37:24 -04:00
parent 331032eb3c
commit d7376702d2
5 changed files with 10 additions and 27 deletions

View File

@ -170,8 +170,6 @@ more than one section:
# fn foo() {}
```
Let's discuss the details of these code blocks.
#### Code block annotations
To write some Rust code in a comment, use the triple graves:
@ -183,23 +181,8 @@ To write some Rust code in a comment, use the triple graves:
# fn foo() {}
```
If you want something that's not Rust code, you can add an annotation:
```rust
/// ```c
/// printf("Hello, world\n");
/// ```
# fn foo() {}
```
This will highlight according to whatever language you're showing off.
If you're only showing plain text, choose `text`.
It's important to choose the correct annotation here, because `rustdoc` uses it
in an interesting way: It can be used to actually test your examples in a
library crate, so that they don't get out of date. If you have some C code but
`rustdoc` thinks it's Rust because you left off the annotation, `rustdoc` will
complain when trying to generate the documentation.
This will add code highlighting. If you are only showing plain text, put `text`
instead of `rust` after the triple graves (see below).
## Documentation as tests

View File

@ -687,7 +687,7 @@ attribute turns off Rust's name mangling, so that it is easier to link to.
Its important to be mindful of `panic!`s when working with FFI. A `panic!`
across an FFI boundary is undefined behavior. If youre writing code that may
panic, you should run it in a closure with [`catch_unwind()`]:
panic, you should run it in a closure with [`catch_unwind`]:
```rust
use std::panic::catch_unwind;
@ -706,11 +706,11 @@ pub extern fn oh_no() -> i32 {
fn main() {}
```
Please note that [`catch_unwind()`] will only catch unwinding panics, not
those who abort the process. See the documentation of [`catch_unwind()`]
Please note that [`catch_unwind`] will only catch unwinding panics, not
those who abort the process. See the documentation of [`catch_unwind`]
for more information.
[`catch_unwind()`]: ../../std/panic/fn.catch_unwind.html
[`catch_unwind`]: ../../std/panic/fn.catch_unwind.html
# Representing opaque structs

View File

@ -56,7 +56,7 @@ They can be used to manage control flow in a modular fashion.
A type without a statically known size or alignment. ([more info][link])
[link]: ../../nomicon/exotic-sizes.html#dynamically-sized-types-dsts
[link]: ../nomicon/exotic-sizes.html#dynamically-sized-types-dsts
### Expression

View File

@ -217,12 +217,12 @@ The next part will use this handle to get input from the user:
.read_line(&mut guess)
```
Here, we call the [`read_line()`][read_line] method on our handle.
Here, we call the [`read_line`] method on our handle.
[Methods][method] are like associated functions, but are only available on a
particular instance of a type, rather than the type itself. Were also passing
one argument to `read_line()`: `&mut guess`.
[read_line]: ../../std/io/struct.Stdin.html#method.read_line
[`read_line`]: ../../std/io/struct.Stdin.html#method.read_line
[method]: method-syntax.html
Remember how we bound `guess` above? We said it was mutable. However,

View File

@ -147,7 +147,7 @@ And that's reflected in the summary line:
test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
```
We also get a non-zero status code. We can use `$?` on OS X and Linux:
We also get a non-zero status code. We can use `$?` on macOS and Linux:
```bash
$ echo $?