We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 8ba01a1 + b09305e commit f5d1128Copy full SHA for f5d1128
src/libstd/primitive_docs.rs
@@ -12,7 +12,8 @@
12
//
13
/// The boolean type.
14
///
15
-/// 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
16
+/// a `bool` into an integer, `true` will be 1 and `false` will be 0.
17
18
/// # Basic usage
19
@@ -56,6 +57,13 @@
56
57
58
/// Also, since `bool` implements the [`Copy`](marker/trait.Copy.html) trait, we don't
59
/// have to worry about the move semantics (just like the integer and float primitives).
60
+///
61
+/// Now an example of `bool` cast to integer type:
62
63
+/// ```
64
+/// assert_eq!(true as i32, 1);
65
+/// assert_eq!(false as i32, 0);
66
67
#[stable(feature = "rust1", since = "1.0.0")]
68
mod prim_bool { }
69
0 commit comments