]>
Commit | Line | Data |
---|---|---|
1b1a35ee XL |
1 | #![cfg_attr(full, feature(const_generics))] |
2 | #![cfg_attr(full, allow(incomplete_features))] | |
3 | #![cfg_attr(min, feature(min_const_generics))] | |
3dfed10e XL |
4 | |
5 | pub struct Struct<const N: usize>(()); | |
6 | ||
7 | impl<const N: usize> Struct<N> { | |
8 | pub fn new() -> Self { | |
9 | Struct(()) | |
10 | } | |
11 | ||
12 | pub fn same_ty<const M: usize>(&self) -> (usize, usize) { | |
13 | (N, M) | |
14 | } | |
15 | ||
16 | pub fn different_ty<const M: u8>(&self) -> (usize, u8) { | |
17 | (N, M) | |
18 | } | |
19 | ||
20 | pub fn containing_ty<T, const M: u8>(&self) -> (usize, u8) { | |
21 | (std::mem::size_of::<T>() + N, M) | |
22 | } | |
23 | ||
24 | pub fn we_have_to_go_deeper<const M: usize>(&self) -> Struct<M> { | |
25 | Struct(()) | |
26 | } | |
27 | } | |
28 | ||
29 | pub trait Foo { | |
30 | fn foo<const M: usize>(&self) -> usize; | |
31 | } | |
32 | ||
33 | impl Foo for Struct<7> { | |
34 | fn foo<const M: usize>(&self) -> usize { | |
35 | M | |
36 | } | |
37 | } |