Skip to content

Commit 3f38757

Browse files
committed
Add const trait sugar future extension
1 parent 7d86f87 commit 3f38757

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

const-generic-const-fn-bounds.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,22 @@ const fn foo<T: ?const Foo>() -> i32 {
328328

329329
even though the `?const` modifier explicitly opts out of constness.
330330

331+
### `const` traits
332+
333+
A further extension could be `const trait` declarations, which desugar to all methods being `const`:
334+
335+
```rust
336+
const trait V {
337+
fn foo(C) -> D;
338+
fn bar(E) -> F;
339+
}
340+
// ...desugars to...
341+
trait V {
342+
const fn foo(C) -> D;
343+
const fn bar(E) -> F;
344+
}
345+
```
346+
331347
## `?const` modifiers in trait methods
332348

333349
This RFC does not touch `trait` methods at all, all traits are defined as they would be defined

0 commit comments

Comments
 (0)