mirror of https://github.com/rust-lang/book
Fix a problem with literal style ending
This commit is contained in:
parent
9a3822ee96
commit
4ad07d9e17
|
@ -26,27 +26,28 @@ Table B-1: Operators
|
|||
| `!` | `ident!(...)`, `ident!{...}`, `ident![...]` | Macro expansion | |
|
||||
| `!` | `!expr` | Bitwise or logical complement | `Not` |
|
||||
| `!=` | `expr != expr` | Nonequality comparison | `PartialEq` |
|
||||
| `% | `expr % expr` | Arithmetic remainder | `Rem` |
|
||||
| `%` | `expr % expr` | Arithmetic remainder | `Rem` |
|
||||
| `%=` | `var %= expr` | Arithmetic remainder and assignment | `RemAssign` |
|
||||
| `& | `&expr`, `&mut expr` | Borrow | |
|
||||
| `&` | `&expr`, `&mut expr` | Borrow | |
|
||||
| `&` | `&type`, `&mut type`, `&'a type`, `&'a mut type` | Borrowed pointer
|
||||
type | |
|
||||
| `&` | `expr & expr` | Bitwise AND | `BitAnd` |
|
||||
| `&=` | `var &= expr` | Bitwise AND and assignment | `BitAndAssign` |
|
||||
| `&&` | `expr && expr` | Short-circuiting logical AND | |
|
||||
| `* | `expr * expr` | Arithmetic multiplication | `Mul` |
|
||||
| `*` | `expr * expr` | Arithmetic multiplication | `Mul` |
|
||||
| `*=` | `var *= expr` | Arithmetic multiplication and assignment | `MulAssign`
|
||||
|
|
||||
| `*` | `*expr` | Dereference | `Deref` |
|
||||
| `*` | `*const type`, `*mut type | Raw pointer | |
|
||||
| `+ | `trait + trait`, `'a + trait` | Compound type constraint | |
|
||||
| `+ | `expr + expr` | Arithmetic addition | `Add` |
|
||||
| `*` | `*const type`, `*mut type` | Raw pointer | |
|
||||
| `+` | `trait + trait`, `'a + trait` | Compound type constraint | |
|
||||
| `+` | `expr + expr` | Arithmetic addition | `Add` |
|
||||
| `+=` | `var += expr` | Arithmetic addition and assignment | `AddAssign` |
|
||||
| `,` | `expr, expr` | Argument and element separator | |
|
||||
| `- | `- expr` | Arithmetic negation | `Neg` |
|
||||
| `- | `expr - expr` | Arithmetic subtraction | `Sub` |
|
||||
| `-` | `- expr` | Arithmetic negation | `Neg` |
|
||||
| `-` | `expr - expr` | Arithmetic subtraction | `Sub` |
|
||||
| `-=` | `var -= expr` | Arithmetic subtraction and assignment | `SubAssign` |
|
||||
| `-> | `fn(...) -> type`, `|…| -> type` | Function and closure return type | |
|
||||
| `->` | `fn(...) -> type`, `|…| -> type` | Function and closure return type |
|
||||
|
|
||||
| `. | `expr.ident` | Member access | |
|
||||
| `..` | `..`, `expr..`, `..expr`, `expr..expr` | Right-exclusive range literal
|
||||
| `PartialOrd` |
|
||||
|
@ -57,12 +58,12 @@ type | |
|
|||
binding | |
|
||||
| `...` | `expr...expr` | (Deprecated, use `..=` instead) In a pattern:
|
||||
inclusive range pattern | |
|
||||
| `/ | `expr / expr` | Arithmetic division | `Div` |
|
||||
| `/` | `expr / expr` | Arithmetic division | `Div` |
|
||||
| `/=` | `var /= expr` | Arithmetic division and assignment | `DivAssign` |
|
||||
| `: | `pat: type`, `ident: type` | Constraints | |
|
||||
| `:` | `ident: expr` | Struct field initializer | |
|
||||
| `:` | `'a: loop {...}` | Loop label | |
|
||||
| `; | `expr;` | Statement and item terminator | |
|
||||
| `;` | `expr;` | Statement and item terminator | |
|
||||
| `;` | `[...; len]` | Part of fixed-size array syntax | |
|
||||
| `<<` | `expr << expr` | Left-shift | `Shl` |
|
||||
| `<<=` | `var <<= expr` | Left-shift and assignment | `ShlAssign` |
|
||||
|
@ -75,14 +76,14 @@ inclusive range pattern | |
|
|||
| `>=` | `expr >= expr` | Greater than or equal to comparison | `PartialOrd` |
|
||||
| `>>` | `expr >> expr` | Right-shift | `Shr` |
|
||||
| `>>=` | `var >>= expr` | Right-shift and assignment | `ShrAssign` |
|
||||
| `@ | `ident @ pat` | Pattern binding | |
|
||||
| `@` | `ident @ pat` | Pattern binding | |
|
||||
| `^` | `expr ^ expr` | Bitwise exclusive OR | `BitXor` |
|
||||
| `^=` | `var ^= expr` | Bitwise exclusive OR and assignment | `BitXorAssign` |
|
||||
| `| | `pat | pat` | Pattern alternatives | |
|
||||
| `|` | `pat | pat` | Pattern alternatives | |
|
||||
| `|` | `expr | expr` | Bitwise OR | `BitOr` |
|
||||
| `|=` | `var |= expr` | Bitwise OR and assignment | `BitOrAssign` |
|
||||
| `||` | `expr || expr` | Short-circuiting logical OR | |
|
||||
| `? | `expr?` | Error propagation | |
|
||||
| `?` | `expr?` | Error propagation | |
|
||||
|
||||
## Non-operator Symbols
|
||||
|
||||
|
@ -96,21 +97,21 @@ Table B-2: Stand-Alone Syntax
|
|||
|
||||
| Symbol | Explanation |
|
||||
|---|---|
|
||||
| `'ident | Named lifetime or loop label |
|
||||
| `'ident` | Named lifetime or loop label |
|
||||
| `...u8`, `...i32`, `...f64`, `...usize`, and so on | Numeric literal of
|
||||
specific type |
|
||||
| `"..." | String literal |
|
||||
| `"..."` | String literal |
|
||||
| `r"..."`, `r#"..."#`, `r##"..."##`, and so on | Raw string literal; escape
|
||||
characters not processed |
|
||||
| `b"..."` | Byte string literal; constructs an array of bytes instead of a
|
||||
string |
|
||||
| `br"..."`, `br#"..."#`, `br##"..."##`, and so on | Raw byte string literal;
|
||||
combination of raw and byte string literal |
|
||||
| `'...' | Character literal |
|
||||
| `b'...' | ASCII byte literal |
|
||||
| `|…| expr | Closure |
|
||||
| `! | Always-empty bottom type for diverging functions |
|
||||
| `_ | “Ignored” pattern binding; also used to make integer literals readable |
|
||||
| `'...'` | Character literal |
|
||||
| `b'...'` | ASCII byte literal |
|
||||
| `|…| expr` | Closure |
|
||||
| `!` | Always-empty bottom type for diverging functions |
|
||||
| `_` | “Ignored” pattern binding; also used to make integer literals readable |
|
||||
|
||||
Table B-3 shows symbols that appear in the context of a path through the module
|
||||
hierarchy to an item.
|
||||
|
@ -119,14 +120,14 @@ Table B-3: Path-Related Syntax
|
|||
|
||||
| Symbol | Explanation |
|
||||
|---|---|
|
||||
| `ident::ident | Namespace path |
|
||||
| `ident::ident` | Namespace path |
|
||||
| `::path` | Path relative to the crate root (that is, an explicitly absolute
|
||||
path) |
|
||||
| `self::path` | Path relative to the current module (that is, an explicitly
|
||||
relative path) |
|
||||
| `super::path` | Path relative to the parent of the current module |
|
||||
| `type::ident`, `<type as trait>::ident | Associated constants, functions, and
|
||||
types |
|
||||
| `type::ident`, `<type as trait>::ident` | Associated constants, functions,
|
||||
and types |
|
||||
| `<type>::...` | Associated item for a type that cannot be directly named (for
|
||||
example, `<&T>::...`, `<[T]>::...`, and so on) |
|
||||
| `trait::method(...)` | Disambiguating a method call by naming the trait that
|
||||
|
@ -205,7 +206,7 @@ Table B-8: Tuples
|
|||
|
||||
| Symbol | Explanation |
|
||||
|---|---|
|
||||
| `() | Empty tuple (aka unit), both literal and type |
|
||||
| `()` | Empty tuple (aka unit), both literal and type |
|
||||
| `(expr)` | Parenthesized expression |
|
||||
| `(expr,)` | Single-element tuple expression |
|
||||
| `(type,)` | Single-element tuple type |
|
||||
|
|
|
@ -134,7 +134,7 @@ program:
|
|||
fn main() {
|
||||
```
|
||||
|
||||
The `fn` syntax declares a new function; the parentheses, `(), indicate there
|
||||
The `fn` syntax declares a new function; the parentheses, `()`, indicate there
|
||||
are no parameters; and the curly bracket, `{`, starts the body of the function.
|
||||
|
||||
As you also learned in Chapter 1, `println!` is a macro that prints a string to
|
||||
|
@ -222,7 +222,7 @@ standard input and append that into a string (without overwriting its
|
|||
contents), so we therefore pass that string as an argument. The string argument
|
||||
needs to be mutable so the method can change the string’s content.
|
||||
|
||||
The `& indicates that this argument is a *reference*, which gives you a way to
|
||||
The `&` indicates that this argument is a *reference*, which gives you a way to
|
||||
let multiple parts of your code access one piece of data without needing to
|
||||
copy that data into memory multiple times. References are a complex feature,
|
||||
and one of Rust’s major advantages is how safe and easy it is to use
|
||||
|
@ -475,11 +475,11 @@ checked into source control with the rest of the code in your project.
|
|||
|
||||
#### Updating a Crate to Get a New Version
|
||||
|
||||
When you *do* want to update a crate, Cargo provides the command `update, which
|
||||
will ignore the *Cargo.lock* file and figure out all the latest versions that
|
||||
fit your specifications in *Cargo.toml*. Cargo will then write those versions
|
||||
to the *Cargo.lock* file. Otherwise, by default, Cargo will only look for
|
||||
versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has
|
||||
When you *do* want to update a crate, Cargo provides the command `update`,
|
||||
which will ignore the *Cargo.lock* file and figure out all the latest versions
|
||||
that fit your specifications in *Cargo.toml*. Cargo will then write those
|
||||
versions to the *Cargo.lock* file. Otherwise, by default, Cargo will only look
|
||||
for versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has
|
||||
released the two new versions 0.8.6 and 0.9.0, you would see the following if
|
||||
you ran `cargo update`:
|
||||
|
||||
|
@ -865,7 +865,7 @@ match guess.cmp(&secret_number) {
|
|||
}
|
||||
```
|
||||
|
||||
Adding the `break line after `You win!` makes the program exit the loop when
|
||||
Adding the `break` line after `You win!` makes the program exit the loop when
|
||||
the user guesses the secret number correctly. Exiting the loop also means
|
||||
exiting the program, because the loop is the last part of `main`.
|
||||
|
||||
|
@ -913,12 +913,12 @@ will end up right where we want it in the new `guess` variable we’re creating.
|
|||
If `parse` is *not* able to turn the string into a number, it will return an
|
||||
`Err` value that contains more information about the error. The `Err` value
|
||||
does not match the `Ok(num)` pattern in the first `match` arm, but it does
|
||||
match the `Err(_)` pattern in the second arm. The underscore, `_, is a catchall
|
||||
value; in this example, we’re saying we want to match all `Err` values, no
|
||||
matter what information they have inside them. So the program will execute the
|
||||
second arm’s code, `continue, which tells the program to go to the next
|
||||
iteration of the `loop` and ask for another guess. So, effectively, the program
|
||||
ignores all errors that `parse` might encounter!
|
||||
match the `Err(_)` pattern in the second arm. The underscore, `_`, is a
|
||||
catchall value; in this example, we’re saying we want to match all `Err`
|
||||
values, no matter what information they have inside them. So the program will
|
||||
execute the second arm’s code, `continue`, which tells the program to go to the
|
||||
next iteration of the `loop` and ask for another guess. So, effectively, the
|
||||
program ignores all errors that `parse` might encounter!
|
||||
|
||||
Now everything in the program should work as expected. Let’s try it:
|
||||
|
||||
|
|
|
@ -355,7 +355,7 @@ Unmatched: <xsl:value-of select="w:pPr/w:pStyle/@w:val" />
|
|||
<xsl:text>`</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:value-of select="normalize-space(w:t)" />
|
||||
<xsl:if test="not(following-sibling::*[1][self::w:r]) or following-sibling::w:r[1][not(w:rPr/w:rStyle/@w:val = 'Literal') and not(w:rPr/w:rStyle/@w:val = 'LiteralBold') and not(w:rPr/w:rStyle/@w:val = 'LiteralCaption') and not(w:rPr/w:rStyle/@w:val = 'LiteralBox')]">
|
||||
<xsl:if test="not(following-sibling::*[1][self::w:r]) or following-sibling::w:r[1][not(w:rPr/w:rStyle/@w:val = 'Literal') and not(w:rPr/w:rStyle/@w:val = 'LiteralBold') and not(w:rPr/w:rStyle/@w:val = 'LiteralCaption') and not(w:rPr/w:rStyle/@w:val = 'LiteralBox')] or following-sibling::w:r[1][w:rPr/w:rStyle/@w:val = 'Literal' and not(w:t)]">
|
||||
<xsl:text>`</xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:if test="substring(w:t, string-length(w:t)) = ' '">
|
||||
|
|
Loading…
Reference in New Issue