Skip to content

Commit 27a1c56

Browse files
authored
Rollup merge of rust-lang#108675 - Shadlock0133:adt_const_params, r=compiler-errors
Document `adt_const_params` feature in Unstable Book
2 parents ed19532 + 69e5d7d commit 27a1c56

File tree

1 file changed

+32
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)