@@ -102,7 +102,9 @@ mod break_keyword {}
102
102
103
103
#[ doc( keyword = "const" ) ]
104
104
//
105
- /// Compile-time constants and deterministic functions.
105
+ /// Compile-time constants and compile-time evaluable functions.
106
+ ///
107
+ /// ## Compile-time constants
106
108
///
107
109
/// Sometimes a certain value is used many times throughout a program, and it can become
108
110
/// inconvenient to copy it over and over. What's more, it's not always possible or desirable to
@@ -145,15 +147,28 @@ mod break_keyword {}
145
147
///
146
148
/// Constants, like statics, should always be in `SCREAMING_SNAKE_CASE`.
147
149
///
150
+ /// For more detail on `const`, see the [Rust Book] or the [Reference].
151
+ ///
152
+ /// ## Compile-time evaluable functions
153
+ ///
154
+ /// The other main use of the `const` keyword is in `const fn`. This marks a function as being
155
+ /// callable in the body of a `const` or `static` item and in array initializers (commonly called
156
+ /// "const contexts"). `const fn` are restricted in the set of operations they can perform, to
157
+ /// ensure that they can be evaluated at compile-time. See the [Reference][const-eval] for more
158
+ /// detail.
159
+ ///
160
+ /// Turning a `fn` into a `const fn` has no effect on run-time uses of that function.
161
+ ///
162
+ /// ## Other uses of `const`
163
+ ///
148
164
/// The `const` keyword is also used in raw pointers in combination with `mut`, as seen in `*const
149
165
/// T` and `*mut T`. More about `const` as used in raw pointers can be read at the Rust docs for the [pointer primitive].
150
166
///
151
- /// For more detail on `const`, see the [Rust Book] or the [Reference].
152
- ///
153
167
/// [pointer primitive]: primitive.pointer.html
154
168
/// [Rust Book]:
155
169
/// ../book/ch03-01-variables-and-mutability.html#differences-between-variables-and-constants
156
170
/// [Reference]: ../reference/items/constant-items.html
171
+ /// [cosnt-eval]: ./reference/const_eval.html
157
172
mod const_keyword { }
158
173
159
174
#[ doc( keyword = "continue" ) ]
0 commit comments