[][src]Trait az::WrappingAs

pub trait WrappingAs {
    fn wrapping_as<Dst>(self) -> Dst
    where
        Self: WrappingCast<Dst>
; }

Wrapping cast.

This is a convenience trait to enable writing src.wrapping_as::<Dst>(). This would not work with the WrappingCast::wrapping_cast method because the WrappingCast trait is generic while the wrapping_cast method is not generic.

This trait’s method is suitable for chaining.

Panics

This trait’s method panics if the value does not fit and cannot be wrapped, for example when trying to cast floating-point ∞ into an integer type.

Examples

use az::WrappingAs;
assert_eq!((-1).wrapping_as::<u32>(), u32::max_value());
assert_eq!((17.0 + 256.0).wrapping_as::<u8>(), 17);

Required methods

fn wrapping_as<Dst>(self) -> Dst where
    Self: WrappingCast<Dst>, 

Casts the value.

Loading content...

Implementors

impl<T> WrappingAs for T[src]

Loading content...