Traits for conversions between types.
The traits in this module provide a general way to talk about conversions
from one type to another. They follow the standard Rust conventions of
Like many traits, these are often used as bounds for generic functions, to support arguments of multiple types.
- Impl the
As*traits for reference-to-reference conversions
- Impl the
Intotrait when you want to consume the value in the conversion
Fromtrait is the most flexible, useful for value and reference conversions
TryIntotraits behave like
Into, but allow for the conversion to fail
As a library author, you should prefer implementing
TryFrom<T> rather than
TryFrom provide greater flexibility and offer
TryInto implementations for free, thanks to a blanket implementation
in the standard library.
AsMutauto-dereference if the inner type is a reference
From<U> for Timplies
Into<T> for U
TryFrom<U> for Timplies
TryInto<T> for U
Intoare reflexive, which means that all types can
See each trait for usage examples.
A cheap, mutable reference-to-mutable reference conversion.
A cheap, reference-to-reference conversion.
A conversion that consumes
Attempt to construct
An attempted conversion that consumes