You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/const_eval.md
+26-11Lines changed: 26 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -258,27 +258,39 @@ generics.
258
258
r[const-eval.const-fn]
259
259
## Const functions
260
260
261
-
r[const-eval.const-fn.general]
262
-
A _const fn_ is a function that one is permitted to call from a const context.
261
+
r[const-eval.const-fn.intro]
262
+
A _const function_ is a function that can be called from a const context.It is defined with the `const` qualifier, and also includes [tuple struct] and [tuple enum variant] constructors.
263
263
264
-
r[const-eval.const-fn.usage]
265
-
Declaring a function
266
-
`const` has no effect on any existing uses, it only restricts the types that arguments and the
267
-
returntype may use, and restricts the function body to constant expressions.
264
+
> [!EXAMPLE]
265
+
> ```rust
266
+
> constfn square(x:i32) ->i32 { x * x }
267
+
>
268
+
> constVALUE:i32= square(12);
269
+
> ```
268
270
269
271
r[const-eval.const-fn.const-context]
270
-
When called from a const context, the function is interpreted by the
271
-
compiler at compile time.The interpretation happens in the
272
-
environment of the compilation target and not the host.So `usize` is
273
-
`32` bits if you are compiling against a `32` bit system, irrelevant
274
-
of whether you are building on a `64` bit or a `32` bit system.
Copy file name to clipboardExpand all lines: src/items/functions.md
+1-11Lines changed: 1 addition & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -279,14 +279,7 @@ For other considerations and limitations regarding unwinding across FFI boundari
279
279
r[items.fn.const]
280
280
## Const functions
281
281
282
-
r[items.fn.const.intro]
283
-
Functions qualified with the `const` keyword are [const functions], as are [tuple struct] and [tuple enum variant] constructors. _Const functions_ can be called from within [const contexts].
284
-
285
-
r[items.fn.const.extern]
286
-
Const functions may use the [`extern`] function qualifier.
287
-
288
-
r[items.fn.const.exclusivity]
289
-
Const functions are not allowed to be [async](#async-functions).
282
+
See [const functions] for the definition of const functions.
0 commit comments