Skip to content

Commit

Permalink
Add test for try operator with Option
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Aug 2, 2021
1 parent 7c8c209 commit b7f572b
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/test/ui/consts/try-operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
#![feature(const_identity_convert)]

fn main() {
const fn foo() -> Result<bool, ()> {
const fn result() -> Result<bool, ()> {
Err(())?;
Ok(true)
}

const FOO: Result<bool, ()> = foo();
const FOO: Result<bool, ()> = result();
assert_eq!(Err(()), FOO);

const fn option() -> Option<()> {
None?;
Some(())
}
const BAR: Option<()> = option();
assert_eq!(None, BAR);
}

0 comments on commit b7f572b

Please sign in to comment.