mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-23 23:50:25 +08:00
commit
ddd3041ded
@ -78,7 +78,7 @@ the scope of this book).
|
||||
|
||||
Each signed variant can store numbers from -(2<sup>n - 1</sup>) to 2<sup>n -
|
||||
1</sup> - 1 inclusive, where `n` is the number of bits that variant uses. So an
|
||||
`i8` can store numbers from -(2<sup>7</sup>) to 2<sup>7</sup>, which equals
|
||||
`i8` can store numbers from -(2<sup>7</sup>) to 2<sup>7</sup> - 1, which equals
|
||||
-128 to 127. Unsigned variants can store numbers from 0 to 2<sup>n</sup> - 1,
|
||||
so a `u8` can store numbers from 0 to 2<sup>8</sup> - 1, which equals 0 to 255.
|
||||
|
||||
|
@ -35,12 +35,12 @@ condition. In this case, the condition checks whether or not the variable
|
||||
condition is true is placed immediately after the condition inside curly
|
||||
braces. Blocks of code associated with the conditions in `if` expressions are
|
||||
sometimes called *arms*, just like the arms in `match` expressions that we
|
||||
discussed in the “Comparing the Guess to the Secret Number” section of Chapter
|
||||
2. Optionally, we can also include an `else` expression, which we chose to do
|
||||
here, to give the program an alternative block of code to execute should the
|
||||
condition evaluate to false. If you don’t provide an `else` expression and the
|
||||
condition is false, the program will just skip the `if` block and move on to
|
||||
the next bit of code.
|
||||
discussed in the “Comparing the Guess to the Secret Number” section of
|
||||
Chapter 2. Optionally, we can also include an `else` expression, which we chose
|
||||
to do here, to give the program an alternative block of code to execute should
|
||||
the condition evaluate to false. If you don’t provide an `else` expression and
|
||||
the condition is false, the program will just skip the `if` block and move on
|
||||
to the next bit of code.
|
||||
|
||||
Try running this code; you should see the following output:
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user