blob: 2d1eb2678541c30f21b8d74dc26aef5b367deb60 (
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
|
// FIXME: Once https://github.com/rust-lang/rust/pull/69201 makes its
// way into stable, move this back into `project.rs
#[test]
#[project]
fn project_if_let() {
#[pin_project]
enum Foo<A, B> {
Variant1(#[pin] A),
Variant2(u8),
Variant3 {
#[pin] field: B
}
}
let mut foo: Foo<bool, f32> = Foo::Variant1(true);
let foo = Pin::new(&mut foo).project();
#[project]
if let Foo::Variant1(a) = foo {
let a: Pin<&mut bool> = a;
assert_eq!(*a, true);
} else if let Foo::Variant2(_) = foo {
unreachable!();
} else if let Foo::Variant3 { .. } = foo {
unreachable!();
}
}
|