-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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!(); | ||
} | ||
} | ||
|