Crate enumx[][src]

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 enums 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 what impl_trait!{} and impl_super_traits!{} does, e.g. impl_all_traits!{ _impl!(Args) Fn<Args> _for!( Type )} will implement Fn, FnMut and FnOnce for Type.

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 implement FnMut and FnOnce for Type, but NOT Fn.

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

EnumToEnum

Used in ExchangeFrom/ExchangeInto to distinguish conversions between enums from those between an enum and its variant.

Traits

ExchangeFrom

Constructs an enum from one of its variants, or from an enum composed of a subset of its variants.

ExchangeInto

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.

FromVariant

Constructs an enum from one of its variants.

IntoEnum

Wraps a variant into an enum.

Proto

Indicates the prototype for a user-defined Exchange-able enum.

Type Definitions

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” in match 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 defined enums

FromVariant

Derives the trait enumx::FromVariant for user defined enum types.

Proto

Since enums in Rust do not have prototypes, this macro derives them.