macro_rules! one_of {
($a:ty, $b:ty) => { ... };
($a:ty, $b:ty, $c:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty, $h:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty, $h:ty, $i:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty, $h:ty, $i:ty, $j:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty, $h:ty, $i:ty, $j:ty, $k:ty) => { ... };
($a:ty, $b:ty, $c:ty, $d:ty, $e:ty, $f:ty, $g:ty, $h:ty, $i:ty, $j:ty, $k:ty, $l:ty) => { ... };
}Expand description
Represents a type that can be converted either From or TryInto the given types
Also conditionally implements Clone, Copy, Debug, Display, Eq, Hash and PartialEq
Accepts at least 2 types, up to 12 types
§Examples
§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());