Skip to content

Commit 627a2e2

Browse files
committed
Document adt_const_params feature in Unstable Book
1 parent 13471d3 commit 627a2e2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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+
#[derive(ConstParamTy, PartialEq, Eq)]
16+
enum Foo {
17+
A,
18+
B,
19+
C,
20+
}
21+
22+
#[derive(ConstParamTy, PartialEq, Eq)]
23+
struct Bar {
24+
flag: bool,
25+
}
26+
27+
fn is_foo_a_and_bar_true<const F: Foo, const B: Bar>() -> bool {
28+
match (F, B.flag) {
29+
(Foo::A, true) => true,
30+
_ => false,
31+
}
32+
}
33+
```

0 commit comments

Comments
 (0)