[][src]Trait conv::ConvUtil

pub trait ConvUtil {
    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>
, { ... } }

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

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.

fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err> where
    Self: Sized + ApproxInto<Dst, Scheme>,
    Scheme: ApproxScheme

Approximate the subject to a given type with a specific scheme.

fn into_as<Dst>(self) -> Dst where
    Self: Sized + Into<Dst>, 

Convert the subject to a given type.

fn try_as<Dst>(self) -> Result<Dst, Self::Err> where
    Self: Sized + TryInto<Dst>, 

Attempt to convert the subject to a given type.

fn value_as<Dst>(self) -> Result<Dst, Self::Err> where
    Self: Sized + ValueInto<Dst>, 

Attempt a value conversion of the subject to a given type.

Loading content...

Implementors

impl<T> ConvUtil for T[src]

Loading content...