File tree 1 file changed +10
-0
lines changed
1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -836,3 +836,13 @@ Just like `const fn foo(x: impl ~const Trait) { x.method() }` and `const fn foo(
836
836
837
837
There is nothing design-wise blocking function pointers and calling them, they mainly require implementation work and extending the
838
838
compiler's internal type system representation of a function signature to include constness.
839
+
840
+ ## ` const ` closures
841
+
842
+ Closures need explicit opt-in to be callable in const contexts.
843
+ You can already use closures in const contexts today to e.g. declare consts of function pointer type.
844
+ So what we additionally need is some syntax like ` const || {} ` to declare a closure that implements
845
+ ` const Fn() ` . See also [ this tracking issue] ( https://github.com/rust-lang/project-const-traits/issues/10 )
846
+ While it may seem tempting to just automatically implement ` const Fn() ` (or ` ~const Fn() ` ) where applicable,
847
+ it's not clear that this can be done, and there are definite situations where it can't be done.
848
+ As further experimentation is needed here, const closures are not part of this RFC.
You can’t perform that action at this time.
0 commit comments