Fix a problem with literal style ending

This commit is contained in:
Carol (Nichols || Goulding) 2022-09-13 21:24:50 -04:00 committed by Carol (Nichols || Goulding)
parent 9a3822ee96
commit 4ad07d9e17
3 changed files with 41 additions and 40 deletions

View File

@ -26,27 +26,28 @@ Table B-1: Operators
| `!` | `ident!(...)`, `ident!{...}`, `ident![...]` | Macro expansion | | | `!` | `ident!(...)`, `ident!{...}`, `ident![...]` | Macro expansion | |
| `!` | `!expr` | Bitwise or logical complement | `Not` | | `!` | `!expr` | Bitwise or logical complement | `Not` |
| `!=` | `expr != expr` | Nonequality comparison | `PartialEq` | | `!=` | `expr != expr` | Nonequality comparison | `PartialEq` |
| `% | `expr % expr` | Arithmetic remainder | `Rem` | | `%` | `expr % expr` | Arithmetic remainder | `Rem` |
| `%=` | `var %= expr` | Arithmetic remainder and assignment | `RemAssign` | | `%=` | `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`, `&mut type`, `&'a type`, `&'a mut type` | Borrowed pointer
type | | type | |
| `&` | `expr & expr` | Bitwise AND | `BitAnd` | | `&` | `expr & expr` | Bitwise AND | `BitAnd` |
| `&=` | `var &= expr` | Bitwise AND and assignment | `BitAndAssign` | | `&=` | `var &= expr` | Bitwise AND and assignment | `BitAndAssign` |
| `&&` | `expr && expr` | Short-circuiting logical AND | | | `&&` | `expr && expr` | Short-circuiting logical AND | |
| `* | `expr * expr` | Arithmetic multiplication | `Mul` | | `*` | `expr * expr` | Arithmetic multiplication | `Mul` |
| `*=` | `var *= expr` | Arithmetic multiplication and assignment | `MulAssign` | `*=` | `var *= expr` | Arithmetic multiplication and assignment | `MulAssign`
| |
| `*` | `*expr` | Dereference | `Deref` | | `*` | `*expr` | Dereference | `Deref` |
| `*` | `*const type`, `*mut type | Raw pointer | | | `*` | `*const type`, `*mut type` | Raw pointer | |
| `+ | `trait + trait`, `'a + trait` | Compound type constraint | | | `+` | `trait + trait`, `'a + trait` | Compound type constraint | |
| `+ | `expr + expr` | Arithmetic addition | `Add` | | `+` | `expr + expr` | Arithmetic addition | `Add` |
| `+=` | `var += expr` | Arithmetic addition and assignment | `AddAssign` | | `+=` | `var += expr` | Arithmetic addition and assignment | `AddAssign` |
| `,` | `expr, expr` | Argument and element separator | | | `,` | `expr, expr` | Argument and element separator | |
| `- | `- expr` | Arithmetic negation | `Neg` | | `-` | `- expr` | Arithmetic negation | `Neg` |
| `- | `expr - expr` | Arithmetic subtraction | `Sub` | | `-` | `expr - expr` | Arithmetic subtraction | `Sub` |
| `-=` | `var -= expr` | Arithmetic subtraction and assignment | `SubAssign` | | `-=` | `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.ident` | Member access | |
| `..` | `..`, `expr..`, `..expr`, `expr..expr` | Right-exclusive range literal | `..` | `..`, `expr..`, `..expr`, `expr..expr` | Right-exclusive range literal
| `PartialOrd` | | `PartialOrd` |
@ -57,12 +58,12 @@ type | |
binding | | binding | |
| `...` | `expr...expr` | (Deprecated, use `..=` instead) In a pattern: | `...` | `expr...expr` | (Deprecated, use `..=` instead) In a pattern:
inclusive range pattern | | inclusive range pattern | |
| `/ | `expr / expr` | Arithmetic division | `Div` | | `/` | `expr / expr` | Arithmetic division | `Div` |
| `/=` | `var /= expr` | Arithmetic division and assignment | `DivAssign` | | `/=` | `var /= expr` | Arithmetic division and assignment | `DivAssign` |
| `: | `pat: type`, `ident: type` | Constraints | | | `: | `pat: type`, `ident: type` | Constraints | |
| `:` | `ident: expr` | Struct field initializer | | | `:` | `ident: expr` | Struct field initializer | |
| `:` | `'a: loop {...}` | Loop label | | | `:` | `'a: loop {...}` | Loop label | |
| `; | `expr;` | Statement and item terminator | | | `;` | `expr;` | Statement and item terminator | |
| `;` | `[...; len]` | Part of fixed-size array syntax | | | `;` | `[...; len]` | Part of fixed-size array syntax | |
| `<<` | `expr << expr` | Left-shift | `Shl` | | `<<` | `expr << expr` | Left-shift | `Shl` |
| `<<=` | `var <<= expr` | Left-shift and assignment | `ShlAssign` | | `<<=` | `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` | Greater than or equal to comparison | `PartialOrd` |
| `>>` | `expr >> expr` | Right-shift | `Shr` | | `>>` | `expr >> expr` | Right-shift | `Shr` |
| `>>=` | `var >>= expr` | Right-shift and assignment | `ShrAssign` | | `>>=` | `var >>= expr` | Right-shift and assignment | `ShrAssign` |
| `@ | `ident @ pat` | Pattern binding | | | `@` | `ident @ pat` | Pattern binding | |
| `^` | `expr ^ expr` | Bitwise exclusive OR | `BitXor` | | `^` | `expr ^ expr` | Bitwise exclusive OR | `BitXor` |
| `^=` | `var ^= expr` | Bitwise exclusive OR and assignment | `BitXorAssign` | | `^=` | `var ^= expr` | Bitwise exclusive OR and assignment | `BitXorAssign` |
| `| | `pat | pat` | Pattern alternatives | | | `|` | `pat | pat` | Pattern alternatives | |
| `|` | `expr | expr` | Bitwise OR | `BitOr` | | `|` | `expr | expr` | Bitwise OR | `BitOr` |
| `|=` | `var |= expr` | Bitwise OR and assignment | `BitOrAssign` | | `|=` | `var |= expr` | Bitwise OR and assignment | `BitOrAssign` |
| `||` | `expr || expr` | Short-circuiting logical OR | | | `||` | `expr || expr` | Short-circuiting logical OR | |
| `? | `expr?` | Error propagation | | | `?` | `expr?` | Error propagation | |
## Non-operator Symbols ## Non-operator Symbols
@ -96,21 +97,21 @@ Table B-2: Stand-Alone Syntax
| Symbol | Explanation | | Symbol | Explanation |
|---|---| |---|---|
| `'ident | Named lifetime or loop label | | `'ident` | Named lifetime or loop label |
| `...u8`, `...i32`, `...f64`, `...usize`, and so on | Numeric literal of | `...u8`, `...i32`, `...f64`, `...usize`, and so on | Numeric literal of
specific type | specific type |
| `"..." | String literal | | `"..."` | String literal |
| `r"..."`, `r#"..."#`, `r##"..."##`, and so on | Raw string literal; escape | `r"..."`, `r#"..."#`, `r##"..."##`, and so on | Raw string literal; escape
characters not processed | characters not processed |
| `b"..."` | Byte string literal; constructs an array of bytes instead of a | `b"..."` | Byte string literal; constructs an array of bytes instead of a
string | string |
| `br"..."`, `br#"..."#`, `br##"..."##`, and so on | Raw byte string literal; | `br"..."`, `br#"..."#`, `br##"..."##`, and so on | Raw byte string literal;
combination of raw and byte string literal | combination of raw and byte string literal |
| `'...' | Character literal | | `'...'` | Character literal |
| `b'...' | ASCII byte literal | | `b'...'` | ASCII byte literal |
| `|…| expr | Closure | | `|…| expr` | Closure |
| `! | Always-empty bottom type for diverging functions | | `!` | Always-empty bottom type for diverging functions |
| `_ | “Ignored” pattern binding; also used to make integer literals readable | | `_` | “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 Table B-3 shows symbols that appear in the context of a path through the module
hierarchy to an item. hierarchy to an item.
@ -119,14 +120,14 @@ Table B-3: Path-Related Syntax
| Symbol | Explanation | | Symbol | Explanation |
|---|---| |---|---|
| `ident::ident | Namespace path | | `ident::ident` | Namespace path |
| `::path` | Path relative to the crate root (that is, an explicitly absolute | `::path` | Path relative to the crate root (that is, an explicitly absolute
path) | path) |
| `self::path` | Path relative to the current module (that is, an explicitly | `self::path` | Path relative to the current module (that is, an explicitly
relative path) | relative path) |
| `super::path` | Path relative to the parent of the current module | | `super::path` | Path relative to the parent of the current module |
| `type::ident`, `<type as trait>::ident | Associated constants, functions, and | `type::ident`, `<type as trait>::ident` | Associated constants, functions,
types | and types |
| `<type>::...` | Associated item for a type that cannot be directly named (for | `<type>::...` | Associated item for a type that cannot be directly named (for
example, `<&T>::...`, `<[T]>::...`, and so on) | example, `<&T>::...`, `<[T]>::...`, and so on) |
| `trait::method(...)` | Disambiguating a method call by naming the trait that | `trait::method(...)` | Disambiguating a method call by naming the trait that
@ -205,7 +206,7 @@ Table B-8: Tuples
| Symbol | Explanation | | Symbol | Explanation |
|---|---| |---|---|
| `() | Empty tuple (aka unit), both literal and type | | `()` | Empty tuple (aka unit), both literal and type |
| `(expr)` | Parenthesized expression | | `(expr)` | Parenthesized expression |
| `(expr,)` | Single-element tuple expression | | `(expr,)` | Single-element tuple expression |
| `(type,)` | Single-element tuple type | | `(type,)` | Single-element tuple type |

View File

@ -134,7 +134,7 @@ program:
fn main() { 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. 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 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 contents), so we therefore pass that string as an argument. The string argument
needs to be mutable so the method can change the strings content. needs to be mutable so the method can change the strings 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 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, copy that data into memory multiple times. References are a complex feature,
and one of Rusts major advantages is how safe and easy it is to use and one of Rusts 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 #### Updating a Crate to Get a New Version
When you *do* want to update a crate, Cargo provides the command `update, which When you *do* want to update a crate, Cargo provides the command `update`,
will ignore the *Cargo.lock* file and figure out all the latest versions that which will ignore the *Cargo.lock* file and figure out all the latest versions
fit your specifications in *Cargo.toml*. Cargo will then write those versions that fit your specifications in *Cargo.toml*. Cargo will then write those
to the *Cargo.lock* file. Otherwise, by default, Cargo will only look for versions to the *Cargo.lock* file. Otherwise, by default, Cargo will only look
versions greater than 0.8.5 and less than 0.9.0. If the `rand` crate has 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 released the two new versions 0.8.6 and 0.9.0, you would see the following if
you ran `cargo update`: 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 the user guesses the secret number correctly. Exiting the loop also means
exiting the program, because the loop is the last part of `main`. 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 were creating.
If `parse` is *not* able to turn the string into a number, it will return an 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 `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 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 match the `Err(_)` pattern in the second arm. The underscore, `_`, is a
value; in this example, were saying we want to match all `Err` values, no catchall value; in this example, were saying we want to match all `Err`
matter what information they have inside them. So the program will execute the values, no matter what information they have inside them. So the program will
second arms code, `continue, which tells the program to go to the next execute the second arms code, `continue`, which tells the program to go to the
iteration of the `loop` and ask for another guess. So, effectively, the program next iteration of the `loop` and ask for another guess. So, effectively, the
ignores all errors that `parse` might encounter! program ignores all errors that `parse` might encounter!
Now everything in the program should work as expected. Lets try it: Now everything in the program should work as expected. Lets try it:

View File

@ -355,7 +355,7 @@ Unmatched: <xsl:value-of select="w:pPr/w:pStyle/@w:val" />
<xsl:text>`</xsl:text> <xsl:text>`</xsl:text>
</xsl:if> </xsl:if>
<xsl:value-of select="normalize-space(w:t)" /> <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:text>`</xsl:text>
</xsl:if> </xsl:if>
<xsl:if test="substring(w:t, string-length(w:t)) = ' '"> <xsl:if test="substring(w:t, string-length(w:t)) = ' '">