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/items/functions.md
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -170,26 +170,26 @@ If a `const fn` is called outside a "const context", it is indistinguishable fro
170
170
171
171
Exhaustive list of permitted structures in `const fn`:
172
172
173
-
1. type parameters where the parameters have any of the following as part of their bounds (either on `where` or directly on the parameters):
173
+
1. type parameters where the parameters only have any of the following as part of their bounds (either on `where` or directly on the parameters):
174
174
1. lifetimes
175
175
2.`Sized`
176
176
177
-
This means that `<T: 'a + ?Sized>` and `<T: 'b + Sized>`+`<T>` are all permitted.
177
+
This means that `<T: 'a + ?Sized>`, `<T: 'b + Sized>`and`<T>` are all permitted.
178
178
Note that `?Sized` is the absence of a constraint when bounds have been fully elaborated
179
179
which includes adding implicit `Sized` bounds.
180
180
This entails that permitting `Sized` + lifetimes allows the above examples.
181
181
182
182
This rule also applies to type parameters of items that contain `const fn`s.
183
183
184
-
2. arithmetic operators on integers
185
-
3. boolean operators (except for `&&` and `||` which are banned since they are short-circuiting).
184
+
2. arithmetic and comparison operators on integers
185
+
3.all boolean operators except for `&&` and `||` which are banned since they are short-circuiting.
186
186
4. any kind of aggregate constructor (array, `struct`, `enum`, tuple, ...)
187
187
5. calls to other *safe*`const fn`s (methods and functions)
188
188
6. index operations on arrays and slices
189
189
7. field accesses on structs and tuples
190
190
8. reading from constants (but not statics, not even taking a reference to a static)
191
191
9.`&` and `*` (only dereferencing of references, not raw pointers)
192
-
10. casts except for raw pointer to `usize` casts
192
+
10. casts except for raw pointer to integer casts
193
193
11.`const unsafe fn` is allowed, but the body must consist of safe operations only and you won't be able to call the `const unsafe fn` from within another `const fn` even if you use `unsafe`
0 commit comments