Rollup merge of #108675 - Shadlock0133:adt_const_params, r=compiler-errors

Document `adt_const_params` feature in Unstable Book
This commit is contained in:
Matthias Krüger 2024-03-26 21:23:47 +01:00 committed by GitHub
commit 9162776c66
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,35 @@
# `adt_const_params`
The tracking issue for this feature is: [#95174]
[#95174]: https://github.com/rust-lang/rust/issues/95174
------------------------
Allows for using more complex types for const parameters, such as structs or enums.
```rust
#![feature(adt_const_params)]
#![allow(incomplete_features)]
use std::marker::ConstParamTy;
#[derive(ConstParamTy, PartialEq, Eq)]
enum Foo {
A,
B,
C,
}
#[derive(ConstParamTy, PartialEq, Eq)]
struct Bar {
flag: bool,
}
fn is_foo_a_and_bar_true<const F: Foo, const B: Bar>() -> bool {
match (F, B.flag) {
(Foo::A, true) => true,
_ => false,
}
}
```