2021-08-28 16:48:30 -05:00
|
|
|
// check-pass
|
|
|
|
|
2021-05-03 08:25:32 -05:00
|
|
|
pub trait MyTrait<'a> {
|
|
|
|
type Output: 'a;
|
|
|
|
fn gimme_value(&self) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct MyStruct;
|
|
|
|
|
|
|
|
impl<'a> MyTrait<'a> for MyStruct {
|
|
|
|
type Output = &'a usize;
|
|
|
|
fn gimme_value(&self) -> Self::Output {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn meow<T, F>(t: T, f: F)
|
|
|
|
where
|
|
|
|
T: for<'any> MyTrait<'any>,
|
|
|
|
F: for<'any2> Fn(<T as MyTrait<'any2>>::Output),
|
|
|
|
{
|
|
|
|
let v = t.gimme_value();
|
|
|
|
f(v);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let struc = MyStruct;
|
2021-08-28 16:48:30 -05:00
|
|
|
meow(struc, |foo| {
|
2021-05-03 08:25:32 -05:00
|
|
|
println!("{:?}", foo);
|
|
|
|
})
|
|
|
|
}
|