libcore: test Result::unwrap_infallible
This commit is contained in:
parent
a20013b129
commit
9a99a2159b
2 changed files with 24 additions and 0 deletions
|
|
@ -39,6 +39,8 @@
|
|||
#![feature(slice_from_raw_parts)]
|
||||
#![feature(const_slice_from_raw_parts)]
|
||||
#![feature(const_raw_ptr_deref)]
|
||||
#![feature(never_type)]
|
||||
#![feature(unwrap_infallible)]
|
||||
|
||||
extern crate test;
|
||||
|
||||
|
|
|
|||
|
|
@ -197,6 +197,28 @@ pub fn test_unwrap_or_default() {
|
|||
assert_eq!(op2().unwrap_or_default(), 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
pub fn test_unwrap_infallible() {
|
||||
fn infallible_op() -> Result<isize, !> {
|
||||
Ok(666)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op().unwrap_infallible(), 666);
|
||||
|
||||
enum MyNeverToken {}
|
||||
impl From<MyNeverToken> for ! {
|
||||
fn from(never: MyNeverToken) -> ! {
|
||||
match never {}
|
||||
}
|
||||
}
|
||||
|
||||
fn infallible_op2() -> Result<isize, MyNeverToken> {
|
||||
Ok(667)
|
||||
}
|
||||
|
||||
assert_eq!(infallible_op2().unwrap_infallible(), 667);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_try() {
|
||||
fn try_result_some() -> Option<u8> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue