[−][src]Crate one_of
Macro to represent a type that can be converted either From
or Into
the given types
This crate only works on the nightly version of Rust
Usage
use one_of::one_of; // either `u32` or `char` let x: one_of!(u32, char) = 42.into(); assert_eq!(Some(42u32), x.into()); assert_eq!(Option::<char>::None, x.into()); // some type of integer let x: one_of!(i8, i16, i32, i64, u8, u16, u32, u64) = 42.into(); assert_eq!(Option::<i8>::None, x.into()); assert_eq!(Option::<i16>::None, x.into()); assert_eq!(Some(42i32), x.into()); assert_eq!(Option::<i64>::None, x.into()); assert_eq!(Option::<u8>::None, x.into()); assert_eq!(Option::<u16>::None, x.into()); assert_eq!(Option::<u32>::None, x.into()); assert_eq!(Option::<u64>::None, x.into());
Changelog
See CHANGELOG.md
Macros
one_of | Represents a type that can be converted either |