blob: 3ced40230f012033de6307c24ac43f1001144b1a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
// check-pass
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;
meow(struc, |foo| {
println!("{:?}", foo);
})
}
|