File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 1212//
1313/// The boolean type.
1414///
15- /// The `bool` represents a value, which could only be either `true` or `false`.
15+ /// 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.
1617///
1718/// # Basic usage
1819///
5657///
5758/// Also, since `bool` implements the [`Copy`](marker/trait.Copy.html) trait, we don't
5859/// 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+ /// ```
5967#[ stable( feature = "rust1" , since = "1.0.0" ) ]
6068mod prim_bool { }
6169
You can’t perform that action at this time.
0 commit comments