mirror of https://github.com/rust-lang/book
Fix boxes a bit
This commit is contained in:
parent
ecbe0c4ebc
commit
5761b4b39a
|
@ -375,7 +375,7 @@ When you’re compiling in debug mode, Rust includes checks for integer overflow
|
|||
that cause your program to *panic* at runtime if this behavior occurs. Rust
|
||||
uses the term *panicking* when a program exits with an error; we’ll discuss
|
||||
panics in more depth in “Unrecoverable Errors with panic!” on page XX.
|
||||
|
||||
>
|
||||
> When you’re compiling in release mode with the `--release` flag, Rust does
|
||||
*not* include checks for integer overflow that cause panics. Instead, if
|
||||
overflow occurs, Rust performs *two’s complement wrapping*. In short, values
|
||||
|
@ -384,17 +384,17 @@ of the values the type can hold. In the case of a `u8`, the value 256 becomes
|
|||
0, the value 257 becomes 1, and so on. The program won’t panic, but the
|
||||
variable will have a value that probably isn’t what you were expecting it to
|
||||
have. Relying on integer overflow’s wrapping behavior is considered an error.
|
||||
|
||||
>
|
||||
> To explicitly handle the possibility of overflow, you can use these families
|
||||
of methods provided by the standard library for primitive numeric types:
|
||||
|
||||
>
|
||||
> * Wrap in all modes with the `wrapping_*` methods, such as `wrapping_add`.
|
||||
> * Return the `None` value if there is overflow with the `checked_*` methods.
|
||||
> * Return the value and a boolean indicating whether there was overflow with
|
||||
the `overflowing_*` methods.
|
||||
> * Saturate at the value’s minimum or maximum values with the `saturating_*`
|
||||
methods.
|
||||
>
|
||||
|
||||
#### Floating-Point Types
|
||||
|
||||
Rust also has two primitive types for *floating-point numbers*, which are
|
||||
|
|
|
@ -101,9 +101,14 @@
|
|||
<xsl:text>> * </xsl:text>
|
||||
<xsl:apply-templates select="*" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:if test="not(following-sibling::*[1][self::w:p]) or following-sibling::w:p[1][w:pPr/w:pStyle[@w:val != 'BoxListBullet']]">
|
||||
<xsl:text>> </xsl:text>
|
||||
</xsl:if>
|
||||
<xsl:choose>
|
||||
<xsl:when test="following-sibling::w:p[1][w:pPr/w:pStyle[@w:val = 'BoxBody']]">
|
||||
<xsl:text>> </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:when test="not(following-sibling::*[1][self::w:p])">
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:when>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'BulletC' or @w:val = 'ListPlainC']]">
|
||||
|
@ -199,7 +204,14 @@
|
|||
<xsl:template match="w:p[w:pPr/w:pStyle[@w:val = 'BlockText' or @w:val = 'BoxBody']]">
|
||||
<xsl:text>> </xsl:text>
|
||||
<xsl:apply-templates select="*" />
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:choose>
|
||||
<xsl:when test="following-sibling::w:p[1][w:pPr/w:pStyle/@w:val = 'BlockText' or w:pPr/w:pStyle/@w:val = 'BoxBody' or w:pPr/w:pStyle/@w:val = 'BoxListBullet']">
|
||||
<xsl:text> > </xsl:text>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:text> </xsl:text>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:template>
|
||||
|
||||
<xsl:template match="w:p[w:pPr/w:pStyle/@w:val = 'Note']">
|
||||
|
|
Loading…
Reference in New Issue