Expand description
enumx = ENUM eXtensions.
See the enumx book for more.
Modules§
- export
- Reorganize types, traits and macros to export to end users.
- macros
- The predfined macros for implementing traits for enums
- predefined
- Predefined ad-hoc enums
- proto
- Since
enum
s in Rust do not have prototypes, this mod does the work.
Macros§
- Enum
Enum!( Type0, Type1, ..., TypeM )
denotes a predefined enum, the definition of which looks like:- def_
impls - defines enums, with the syntax support of
- impl_
all_ traits - The
impl_all_traits!{}
macro does whatimpl_trait!{}
andimpl_super_traits!{}
does, e.g.impl_all_traits!{ _impl!(Args) Fn<Args> _for!( Type )}
will implementFn
,FnMut
andFnOnce
forType
. - impl_
super_ traits - The
impl_super_traits!{}
macro helps to implement the super trait(s) of the mentioned trait, e.g.impl_super_traits!{ _impl!(Args) Fn<Args> _for!( Type )}
will implementFnMut
andFnOnce
forType
, but NOTFn
. - impl_
trait - For frequently used traits in std, this library provides macros such as
impl_trait!()
to implement these traits without the need of writing trait methods.
Structs§
- Enum
ToEnum - Used in
ExchangeFrom
/ExchangeInto
to distinguish conversions between enums from those between an enum and its variant.
Traits§
- Exchange
From - Constructs an enum from one of its variants, or from an enum composed of a subset of its variants.
- Exchange
Into - Wraps a variant into an enum, or converts an enum into another one, the variants of which is a superset of the converted enum’s.
- From
Variant - Constructs an enum from one of its variants.
- Into
Enum - Wraps a variant into an enum.
- Proto
- Indicates the prototype for a user-defined
Exchange
-able enum.
Type Aliases§
- TyPat
- Wrapper for non-path types in type pattern matching using
#[ty_pat]
match
Attribute Macros§
- enumx
- tag an
fn
with#[enumx]
to enable “type pattern matching” inmatch
expressions that are tagged with#[ty_pat]
/#[ty_pat(gen_variants)]/
#[ty_pat(gen A,B,..)]`. - sum
- collects all returned values in exit branches of the function, into an enum type, returning an
impl
trait - sum_err
- To translate the
expr?
expressions in a different manner than the Rust’s default:
Derive Macros§
- Exchange
- derives
enumx::Exchange
trait for custom definedenum
s - From
Variant - Derives the trait
enumx::FromVariant
for user defined enum types. - Proto
- Since
enum
s in Rust do not have prototypes, this macro derives them.