]> git.lizzy.rs Git - rust.git/commitdiff
Specify the result of integer cast on boolean
authorGuillaume Gomez <guillaume1.gomez@gmail.com>
Fri, 20 Jan 2017 21:32:12 +0000 (22:32 +0100)
committerGuillaume Gomez <guillaume1.gomez@gmail.com>
Sat, 21 Jan 2017 11:35:43 +0000 (12:35 +0100)
src/libstd/primitive_docs.rs

index a9aa2dc267190281aaa41984042f0e089fc48549..ce6ea2c1257fec69825744eb40195379803983f0 100644 (file)
@@ -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
 ///
 ///
 /// 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 { }