File tree 1 file changed +20
-1
lines changed 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ Some types are defined by the language, rather than as part of the standard
13
13
library, these are called _ primitive types_ . Some of these are individual
14
14
types:
15
15
16
- * The boolean type ` bool ` with values ` true ` and ` false ` .
16
+ * The [ boolean type] ` bool ` with values ` true ` and ` false ` .
17
17
* The [ machine types] (integer and floating-point).
18
18
* The [ machine-dependent integer types] .
19
19
* The [ textual types] ` char ` and ` str ` .
@@ -29,6 +29,7 @@ language:
29
29
* [ References]
30
30
* [ Pointers]
31
31
32
+ [ boolean type ] : #boolean-type
32
33
[ machine types ] : #machine-types
33
34
[ machine-dependent integer types ] : #machine-dependent-integer-types
34
35
[ textual types ] : #textual-types
@@ -44,6 +45,24 @@ language:
44
45
45
46
## Numeric types
46
47
48
+ ### Boolean type
49
+
50
+ The ` bool ` type is a datatype which can be either ` true ` or ` false ` . The boolean
51
+ type uses one byte of memory. It is used in comparisons and bitwise operations
52
+ like ` & ` , ` | ` , and ` ! ` .
53
+
54
+ ``` rust
55
+ fn main () {
56
+ let x = true ;
57
+ let y : bool = false ; // with the boolean type annotation
58
+
59
+ // Use of booleans in conditional expressions
60
+ if x {
61
+ println! (" x is true" );
62
+ }
63
+ }
64
+ ```
65
+
47
66
### Machine types
48
67
49
68
The machine types are the following:
You can’t perform that action at this time.
0 commit comments