Expand description
Macros§
- as_type
- Automatically implement
FromandAsTypefor an enum variant. Example:
Traits§
- AsType
- Conversion methods from a container type (such as an
enum) and a target typeT. - Cast
From - Trait for defining a cast operation from some source type
T. Analogous toFrom. The inverse ofCastInto. Prefer implementingCastFromoverCastIntobecause implementingCastFromautomatically provides an implementation ofCastInto. - Cast
Into - Trait for defining a cast operation to some destination type
T. Analogous toInto. The inverse ofCastFrom. Prefer implementingCastFromoverCastIntobecause implementingCastFromautomatically provides an implementation ofCastInto. - Match
- Blanket implementation of a convenience method
matcheswhich allows callingcan_cast_fromwith a type parameter. Do not implement this trait. - TryCast
From - Trait for defining a cast operation when the source type cannot always be cast to the
destination type. Defines a
can_cast_frommethod which borrows the source value, allowing for pattern matching without moving the value. Whencan_cast_fromreturnstrue, callingopt_cast_frommust returnSome(...), otherwisetry_cast_frommay panic. - TryCast
Into - Trait for defining a cast operation when the destination type cannot always be cast from the
source type. Defines a
can_cast_intomethod which borrowsself, allowing for pattern matching without movingself. Ifcan_cast_intoreturnstrue, then callingopt_cast_intomust returnSome(...), otherwisetry_cast_intomay panic.