blob: 0a358bd164387c30168d8004657301426626cb15 (
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
32
33
34
35
36
|
// check-pass
use std::marker::PhantomData;
#[derive(Default)]
struct MyType<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}
#[derive(Default)]
struct MyTypeVariant<'a> {
field: usize,
_phantom: PhantomData<&'a ()>,
}
trait AsVariantTrait {
type Type;
}
impl<'a> AsVariantTrait for MyType<'a> {
type Type = MyTypeVariant<'a>;
}
type Variant<G> = <G as AsVariantTrait>::Type;
fn foo<T: Default, F: FnOnce(T)>(f: F) {
let input = T::default();
f(input);
}
fn main() {
foo(|a: <MyType as AsVariantTrait>::Type| {
a.field;
});
}
|