[−][src]Crate enumx
Structural enums implemented in enum exchange.
use enumx_derive::EnumX; use enumx::prelude::*; #[derive( EnumX, Debug, PartialEq, Eq, PartialOrd, Ord )] enum One<T> { The(T) } #[derive( EnumX, Debug, PartialEq, Eq, PartialOrd, Ord )] enum Two<A,B> { Former(A), Latter(B) } #[derive( EnumX, Debug, PartialEq, Eq, PartialOrd, Ord )] enum Three<A,B,C> { First(A), Second(B), Third(C), } let one = One::<i32>::enumx_from( 2018 ); let one = One::<i32>::enumx_from( one ); assert_eq!( one, One::The( 2018 )); let two = Two::<String,i32>::enumx_from( one ); assert_eq!( two, Two::Latter( 2018 )); let two = Two::<i32,String>::enumx_from( two ); assert_eq!( two, Two::Former( 2018 )); let three = Three::<bool,String,i32>::enumx_from( two ); assert_eq!( three, Three::Third( 2018 )); let three = Three::<i32,String,bool>::enumx_from( three ); assert_eq!( three, Three::First( 2018 )); let one: One<String> = "rust".to_string().into_enumx(); let one: One<String> = one.into_enumx(); assert_eq!( one, One::The( "rust".to_string() )); let two: Two<i32,String> = one.into_enumx(); assert_eq!( two, Two::Latter( "rust".to_string() )); let two: Two<String,i32> = two.into_enumx(); assert_eq!( two, Two::Former( "rust".to_string() )); let three: Three<bool,i32,String> = two.into_enumx(); assert_eq!( three, Three::Third( "rust".to_string() )); let three: Three<String,i32,bool> = three.into_enumx(); assert_eq!( three, Three::First( "rust".to_string() ));
Modules
prelude |
Macros
Enum |
Structs
AA | |
AN | |
FV | |
LR | Recursive descent indices |
NA | |
NN | |
Nil | Indicates an impossible index for |
V0 | Index of the first variant |
V1 | |
V2 | |
V3 | |
V4 | |
V5 | |
V6 | |
V7 | |
V8 | |
V9 | |
V10 | |
V11 | |
V12 | |
V13 | |
V14 | |
V15 | |
VA | |
VN | |
XF |
Enums
Enum0 | Never type |
Enum1 | |
Enum2 | |
Enum3 | |
Enum4 | |
Enum5 | |
Enum6 | |
Enum7 | |
Enum8 | |
Enum9 | |
Enum10 | |
Enum11 | |
Enum12 | |
Enum13 | |
Enum14 | |
Enum15 | |
Enum16 |
Traits
EnumX | Indicates the prototype for a user-defined exchangeable enum. |
EnumxFrom | Constructs an exchangeable enum from one of its variant type, or from another enum. |
ExchangeFrom | Constructs an exchangeable enum from another one. |
ExchangeInto | Converts an exchangeable enum into another one. |
FromVariant | Constructs an enum from one of its variant type. |
IntoEnum | Converts an exchangeable enum into another one. |
IntoEnumx | Converts a variant, or an exchangeable enum into another exchangeable enum. |