[][src]Macro genie_support::fallible_try_from

macro_rules! fallible_try_from {
    ($to:ty, $from:ident) => { ... };
}

Create a TryFrom implementation for an ID container type that tries to wrap the given number type into the container.

Example

use genie_support::fallible_try_from;
use std::convert::{TryFrom, TryInto};
#[derive(Debug, PartialEq, Eq)]
struct Container(u16);
fallible_try_from!(Container, i16);
assert_eq!(Container::try_from(1i16).unwrap(), Container(1));
assert!(Container::try_from(-1i16).is_err());