2021-10-20 16:56:42 -05:00
|
|
|
trait Trait<const N: u8 = 12> {
|
|
|
|
fn uwu(&self) -> u8 {
|
|
|
|
N
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Trait<2> for u32 {}
|
|
|
|
|
|
|
|
fn foo(arg: &dyn Trait) -> u8 {
|
|
|
|
arg.uwu()
|
|
|
|
}
|
|
|
|
|
|
|
|
trait Traitor<const N: u8 = 1, const M: u8 = N> {
|
|
|
|
fn owo(&self) -> u8 {
|
|
|
|
M
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-18 18:25:14 -05:00
|
|
|
impl Traitor<2, 3> for bool {}
|
2021-10-20 16:56:42 -05:00
|
|
|
|
|
|
|
fn bar<const N: u8>(arg: &dyn Traitor<N>) -> u8 {
|
|
|
|
arg.owo()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
foo(&10_u32);
|
|
|
|
//~^ error: the trait bound `u32: Trait` is not satisfied
|
|
|
|
bar(&true);
|
2022-07-18 18:25:14 -05:00
|
|
|
//~^ error: the trait bound `bool: Traitor<_>` is not satisfied
|
2021-10-20 16:56:42 -05:00
|
|
|
}
|