diff options
| author | bors <bors@rust-lang.org> | 2017-01-21 19:51:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-01-21 19:51:08 +0000 |
| commit | f5d1128a455f50bad162b5aeb2b88441b29f2893 (patch) | |
| tree | 32a5b0dde7340e47f20f1aa536bf780351c5303c /src/libstd | |
| parent | 8ba01a19360d9fae28486c4bdead7e551a6b5c82 (diff) | |
| parent | b09305edb98fcd835abd116327851c65129c24e9 (diff) | |
| download | rust-f5d1128a455f50bad162b5aeb2b88441b29f2893.tar.gz rust-f5d1128a455f50bad162b5aeb2b88441b29f2893.zip | |
Auto merge of #39210 - GuillaumeGomez:GuillaumeGomez-patch-1, r=frewsxcv
Specify the result of integer cast on boolean Fixes #39190. r? @frewsxcv
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/primitive_docs.rs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libstd/primitive_docs.rs b/src/libstd/primitive_docs.rs index a9aa2dc2671..ce6ea2c1257 100644 --- a/src/libstd/primitive_docs.rs +++ b/src/libstd/primitive_docs.rs @@ -12,7 +12,8 @@ // /// The boolean type. /// -/// The `bool` represents a value, which could only be either `true` or `false`. +/// The `bool` represents a value, which could only be either `true` or `false`. If you cast +/// a `bool` into an integer, `true` will be 1 and `false` will be 0. /// /// # Basic usage /// @@ -56,6 +57,13 @@ /// /// Also, since `bool` implements the [`Copy`](marker/trait.Copy.html) trait, we don't /// have to worry about the move semantics (just like the integer and float primitives). +/// +/// Now an example of `bool` cast to integer type: +/// +/// ``` +/// assert_eq!(true as i32, 1); +/// assert_eq!(false as i32, 0); +/// ``` #[stable(feature = "rust1", since = "1.0.0")] mod prim_bool { } |
