Add test for try operator with Option
This commit is contained in:
parent
a042705a7d
commit
aaf902bf8f
1 changed files with 9 additions and 2 deletions
|
@ -6,11 +6,18 @@
|
||||||
#![feature(const_convert)]
|
#![feature(const_convert)]
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
const fn foo() -> Result<bool, ()> {
|
const fn result() -> Result<bool, ()> {
|
||||||
Err(())?;
|
Err(())?;
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const FOO: Result<bool, ()> = foo();
|
const FOO: Result<bool, ()> = result();
|
||||||
assert_eq!(Err(()), FOO);
|
assert_eq!(Err(()), FOO);
|
||||||
|
|
||||||
|
const fn option() -> Option<()> {
|
||||||
|
None?;
|
||||||
|
Some(())
|
||||||
|
}
|
||||||
|
const BAR: Option<()> = option();
|
||||||
|
assert_eq!(None, BAR);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue