]> git.lizzy.rs Git - rust.git/blob - tests/ui/const-generics/type-dependent/auxiliary/type_dependent_lib.rs
Auto merge of #106812 - oli-obk:output_filenames, r=petrochenkov
[rust.git] / tests / ui / const-generics / type-dependent / auxiliary / type_dependent_lib.rs
1 pub struct Struct<const N: usize>(());
2
3 impl<const N: usize> Struct<N> {
4     pub fn new() -> Self {
5         Struct(())
6     }
7
8     pub fn same_ty<const M: usize>(&self) -> (usize, usize) {
9         (N, M)
10     }
11
12     pub fn different_ty<const M: u8>(&self) -> (usize, u8) {
13         (N, M)
14     }
15
16     pub fn containing_ty<T, const M: u8>(&self) -> (usize, u8) {
17         (std::mem::size_of::<T>() +  N, M)
18     }
19
20     pub fn we_have_to_go_deeper<const M: usize>(&self) -> Struct<M> {
21         Struct(())
22     }
23 }
24
25 pub trait Foo {
26     fn foo<const M: usize>(&self) -> usize;
27 }
28
29 impl Foo for Struct<7> {
30     fn foo<const M: usize>(&self) -> usize {
31         M
32     }
33 }