Skip to content

Commit d7df149

Browse files
Rollup merge of rust-lang#108675 - Shadlock0133:adt_const_params, r=compiler-errors
Document `adt_const_params` feature in Unstable Book
2 parents 3b370cf + 17ba73c commit d7df149

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# `adt_const_params`
2+
3+
The tracking issue for this feature is: [#95174]
4+
5+
[#95174]: https://github.com/rust-lang/rust/issues/95174
6+
7+
------------------------
8+
9+
Allows for using more complex types for const parameters, such as structs or enums.
10+
11+
```rust
12+
#![feature(adt_const_params)]
13+
#![allow(incomplete_features)]
14+
15+
use std::marker::ConstParamTy;
16+
17+
#[derive(ConstParamTy, PartialEq, Eq)]
18+
enum Foo {
19+
A,
20+
B,
21+
C,
22+
}
23+
24+
#[derive(ConstParamTy, PartialEq, Eq)]
25+
struct Bar {
26+
flag: bool,
27+
}
28+
29+
fn is_foo_a_and_bar_true<const F: Foo, const B: Bar>() -> bool {
30+
match (F, B.flag) {
31+
(Foo::A, true) => true,
32+
_ => false,
33+
}
34+
}
35+
```

0 commit comments

Comments
 (0)