Skip to content

Commit

Permalink
Rollup merge of rust-lang#108675 - Shadlock0133:adt_const_params, r=c…
Browse files Browse the repository at this point in the history
…ompiler-errors

Document `adt_const_params` feature in Unstable Book
  • Loading branch information
workingjubilee authored Mar 26, 2024
2 parents 3b370cf + 17ba73c commit d7df149
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/doc/unstable-book/src/language-features/adt-const-params.md
Original file line number Diff line number Diff line change
@@ -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,
}
}
```

0 comments on commit d7df149

Please sign in to comment.