pub trait ConvUtil {
// Provided methods
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst> { ... }
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
where Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme { ... }
fn into_as<Dst>(self) -> Dst
where Self: Sized + Into<Dst> { ... }
fn try_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + TryInto<Dst> { ... }
fn value_as<Dst>(self) -> Result<Dst, Self::Err>
where Self: Sized + ValueInto<Dst> { ... }
}
Expand description
This extension trait exists to simplify using various conversions.
If there is more than one implementation for a given type/trait pair, a simple call to *_into
may not be uniquely resolvable. Due to the position of the type parameter (on the trait itself), it is cumbersome to specify the destination type. A similar problem exists for approximation schemes.
See also the ConvAsUtil
trait.
Note: There appears to be a bug in
rustdoc
’s output. This trait is implemented for all types, though the methods are only available for types where the appropriate conversions are defined.
Provided Methods§
Sourcefn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
Sourcefn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>
Approximate the subject to a given type with a specific scheme.