1 unstable release
Uses old Rust 2015
0.1.0 | Apr 20, 2018 |
---|
#15 in #try-from
5KB
51 lines
tryfromfail
Custom derive failing TryFrom
implementations for a set of target types.
Returns the original value as Err(value)
.
Example
#[macro_use]
extern crate tryfromfail;
use std::convert::TryInto;
#[derive(Debug, PartialEq, FailingTryFrom)]
#[FailingTryFrom(OtherType)]
struct SomeType {}
#[derive(Debug, PartialEq)]
struct OtherType {}
#[test]
fn works() {
let val = OtherType {};
let failed_try_from: Result<SomeType, OtherType> = val.try_into();
assert_eq!(failed_try_from, Err(OtherType {}));
}
Dependencies
~2MB
~47K SLoC