Expand description
Macros§
- Automatically implement
From
andAsType
for an enum variant. Example:
Traits§
- Conversion methods from a container type (such as an
enum
) and a target typeT
. - Blanket implementation of a convenience method
matches
which allows callingcan_cast_from
with a type parameter. Do not implement this trait. - Trait for defining a cast operation when the source type cannot always be cast to the destination type. Defines a
can_cast_from
method which borrows the source value, allowing for pattern matching without moving the value. Whencan_cast_from
returnstrue
, callingopt_cast_from
must returnSome(...)
, otherwisetry_cast_from
may panic. - Trait for defining a cast operation when the destination type cannot always be cast from the source type. Defines a
can_cast_into
method which borrowsself
, allowing for pattern matching without movingself
. Ifcan_cast_into
returnstrue
, then callingopt_cast_into
must returnSome(...)
, otherwisetry_cast_into
may panic.