CastInto

Trait CastInto 

Source
pub trait CastInto<T> {
    // Required method
    fn cast_into(self) -> T;
}
Expand description

Cast into another type.

Mirrors Into but with casting semantics. Automatically implemented for all types that implement CastFrom.

Do not implement this trait directly. Implement CastFrom instead.

§Example

use casting::CastInto;

let x: u8 = 42;
let y: u16 = x.cast_into();
assert_eq!(y, 42u16);

Required Methods§

Source

fn cast_into(self) -> T

Casts self into type T.

This method performs a numeric conversion using the as keyword.

Implementors§

Source§

impl<T, U: CastFrom<T>> CastInto<U> for T