mirror of
https://github.com/rust-lang/book.git
synced 2026-09-15 10:10:42 -04:00
@@ -101,7 +101,7 @@ style is to indent with four spaces, not a tab.
|
||||
The second important part is `println!`. This is calling a Rust *macro*,
|
||||
which is how metaprogramming is done in Rust. If it were calling a function
|
||||
instead, it would look like this: `println` (without the `!`). We'll discuss
|
||||
Rust macros in more detail in Chapter 24, but for now you just need to know
|
||||
Rust macros in more detail in Appendix E, but for now you just need to know
|
||||
that when you see a `!` that means that you’re calling a macro instead of a
|
||||
normal function.
|
||||
|
||||
|
||||
@@ -662,7 +662,7 @@ number this time is 38. When the code compares 50 to 38, the `cmp` method will
|
||||
return `Ordering::Greater`, because 50 is greater than 38. `Ordering::Greater`
|
||||
is the value that the `match` expression gets. It looks at the first arm’s
|
||||
pattern, `Ordering::Less`, but the value `Ordering::Greater` does not match
|
||||
`Ordering::Less`. So it ignores the code in that arm and moves to the next arm.
|
||||
`Ordering::Less`, so it ignores the code in that arm and moves to the next arm.
|
||||
The next arm’s pattern, `Ordering::Greater`, *does* match
|
||||
`Ordering::Greater`! The associated code in that arm will execute and print
|
||||
`Too big!` to the screen. The `match` expression ends because it has no need to
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
Rust has an extremely powerful control-flow operator called `match` that allows
|
||||
us to compare a value against a series of patterns and then execute code based
|
||||
on which pattern matches. Patterns can be made up of literal values, variable
|
||||
names, wildcards, and many other things; Chapter 18 will be about all the
|
||||
names, wildcards, and many other things; Chapter 18 will cover all the
|
||||
different kinds of patterns and what they do. The power of `match` comes from
|
||||
the expressiveness of the patterns and the compiler checks that make sure all
|
||||
possible cases are handled.
|
||||
|
||||
Reference in New Issue
Block a user