Trait easy_cast::Cast[][src]

pub trait Cast<T> {
    fn cast(self) -> T;
fn try_cast(self) -> Result<T, Error>; }

Like Into, but for Conv

Two methods are provided:

  • Cast::cast is for “success expected” conversions. In debug builds and when using the always_assert feature flag, inexact conversions will panic. In other cases, conversions may produce incorrect values (according to the behaviour of as). This is similar to the behviour of Rust’s overflow checks on integer arithmetic, and intended for usage when the user is “reasonably sure” that conversion will succeed.
  • Cast::try_cast is for fallible conversions, and always produces an error if the conversion would be inexact.

Required methods

fn cast(self) -> T[src]

Cast from Self to T

fn try_cast(self) -> Result<T, Error>[src]

Try converting from Self to T

Loading content...

Implementors

impl<S, T: Conv<S>> Cast<T> for S[src]

Loading content...