#![cfg_attr(feature = "experimental", feature(try_trait))]
use tear::prelude::*;
#[cfg(not(feature = "experimental"))]
fn f () -> Option<i32> {
terror! { Err(1) => |_| () };
Some(1)
}
#[cfg(feature = "experimental")]
fn f () -> Option<i32> {
use std::option::NoneError;
terror! { Err(1) => |_| NoneError };
Some(1)
}
#[test] fn return_none () {
assert_eq![ f(), None ];
}
#[derive(Debug, PartialEq)]
struct MyInt {
v :i32
}
impl From<i32> for MyInt {
fn from (v :i32) -> MyInt {
MyInt { v }
}
}
#[test] fn terror_from () {
fn f () -> Result<(), MyInt> {
terror! { Err(0) };
Ok(())
}
assert_eq![ f(), Err(MyInt { v: 0 }) ];
}