diff options
| author | bors <bors@rust-lang.org> | 2024-03-29 06:16:56 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-29 06:16:56 +0000 |
| commit | eae940fcef7f95d31b566f92f511f91f24f2f703 (patch) | |
| tree | a5635c4d1821e9114fe7cc27d00353f98cac5402 /src/doc | |
| parent | 58a771ebfa2e59f48cb50229049487c6550b2f7b (diff) | |
| parent | ed29546a27db9fa024c6f99a7dd001e86d75e14f (diff) | |
| download | rust-eae940fcef7f95d31b566f92f511f91f24f2f703.tar.gz rust-eae940fcef7f95d31b566f92f511f91f24f2f703.zip | |
Auto merge of #3427 - rust-lang:rustup-2024-03-29, r=saethlin
Automatic Rustup
Diffstat (limited to 'src/doc')
| -rw-r--r-- | src/doc/unstable-book/src/language-features/adt-const-params.md | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/doc/unstable-book/src/language-features/adt-const-params.md b/src/doc/unstable-book/src/language-features/adt-const-params.md new file mode 100644 index 00000000000..208bf5e4c15 --- /dev/null +++ b/src/doc/unstable-book/src/language-features/adt-const-params.md @@ -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, + } +} +``` |
