Skip to content

Commit 328655a

Browse files
committed
Add comparison for ?const example
1 parent 8d9f649 commit 328655a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

text/0000-const-trait-impls.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,21 @@ do not require const trait impls even if used in const contexts.
745745

746746
An example from libstd today is [the impl block of Vec::new](https://github.com/rust-lang/rust/blob/1ab85fbd7474e8ce84d5283548f21472860de3e2/library/alloc/src/vec/mod.rs#L406) which has an implicit `A: Allocator` bound from [the type definition](https://github.com/rust-lang/rust/blob/1ab85fbd7474e8ce84d5283548f21472860de3e2/library/alloc/src/vec/mod.rs#L397).
747747

748-
A full example how how things would look then
748+
A full example how how
749+
750+
```rust
751+
const trait Foo: ~const Bar + Baz {}
752+
753+
impl const Foo for () {}
754+
755+
const fn foo<T: ~const Foo>() -> T {
756+
// cannot call `Baz` methods
757+
<T as Bar>::bar()
758+
}
759+
760+
const _: () = foo();
761+
```
762+
749763

750764
```rust
751765
const trait Foo: Bar + ?const Baz {}

0 commit comments

Comments
 (0)