Expand description
Macros§
- as_type
- Automatically implement
From
andAsType
for 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 implementingCastFrom
overCastInto
because implementingCastFrom
automatically provides an implementation ofCastInto
. - Cast
Into - Trait for defining a cast operation to some destination type
T
. Analogous toInto
. The inverse ofCastFrom
. Prefer implementingCastFrom
overCastInto
because implementingCastFrom
automatically provides an implementation ofCastInto
. - Match
- Blanket implementation of a convenience method
matches
which allows callingcan_cast_from
with 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_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. - TryCast
Into - 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.