mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 15:40:27 +08:00
Update nostarch file codeblocks to match src
This commit is contained in:
parent
de4ecc002e
commit
effdfa3cda
@ -88,7 +88,7 @@ fn area(length: u32, width: u32) -> u32 {
|
||||
|
||||
Let’s try running this program with `cargo run`:
|
||||
|
||||
```bash
|
||||
```text
|
||||
The area of the rectangle is 1500 square pixels.
|
||||
```
|
||||
|
||||
@ -222,7 +222,7 @@ fn main() {
|
||||
|
||||
If we run this, we get an error with this core message:
|
||||
|
||||
```bash
|
||||
```text
|
||||
error[E0277]: the trait bound `Rectangle: std::fmt::Display` is not satisfied
|
||||
```
|
||||
|
||||
@ -238,7 +238,7 @@ want and structs do not have a provided implementation of `Display`.
|
||||
|
||||
If we keep reading the errors, though, we’ll find this helpful note:
|
||||
|
||||
```bash
|
||||
```text
|
||||
note: `Rectangle` cannot be formatted with the default formatter; try using
|
||||
`:?` instead if you are using a format string
|
||||
```
|
||||
@ -252,13 +252,13 @@ code.
|
||||
|
||||
Let’s try running with this change and… drat. We still get an error:
|
||||
|
||||
```bash
|
||||
```text
|
||||
error: the trait bound `Rectangle: std::fmt::Debug` is not satisfied
|
||||
```
|
||||
|
||||
Again, though, the compiler has given us a helpful note!
|
||||
|
||||
```bash
|
||||
```text
|
||||
note: `Rectangle` cannot be formatted using `:?`; if it is defined in your
|
||||
crate, add `#[derive(Debug)]` or manually implement it
|
||||
```
|
||||
@ -285,7 +285,7 @@ fn main() {
|
||||
At this point, if we run this program, we won’t get any errors and we’ll see
|
||||
the following output:
|
||||
|
||||
```bash
|
||||
```text
|
||||
rect1 is Rectangle { length: 50, width: 30 }
|
||||
```
|
||||
|
||||
@ -441,7 +441,7 @@ fn main() {
|
||||
We want to see this output, since both of `rect2`’s dimensions are smaller than
|
||||
`rect1`’s, but `rect3` is wider than `rect1`:
|
||||
|
||||
```bash
|
||||
```text
|
||||
Can rect1 hold rect2? true
|
||||
Can rect1 hold rect3? false
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user