Skip to main content

Cast

Trait Cast 

Source
pub trait Cast<T> {
    // Required methods
    fn try_cast(self) -> Result<T>;
    fn cast(self) -> T;
}
Expand description

Like Into, but for Conv

This trait is automatically implemented for every implementation of Conv.

Required Methods§

Source

fn try_cast(self) -> Result<T>

Try converting from Self to T

Use this method to explicitly handle errors.

Source

fn cast(self) -> T

Cast from Self to T

Use this method only where success is expected: implementations are permitted to panic or silently return a different (safe, defined) value on error.

In debug builds, implementations must panic.

Implementations by this library will panic in debug builds or if the always_assert feature flag is used, otherwise conversions have the same behaviour as the as keyword.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<S, T: Conv<S>> Cast<T> for S