Skip to main content

IntoSafeCast

Trait IntoSafeCast 

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

Counterpart to the FromSafeCast trait, i.e. this trait is to FromSafeCast what Into is to From.

See the documentation of FromSafeCast for the motivation.

§Examples

use kernel::num::casts::IntoSafeCast;

assert_eq!(0xf00usize, 0xf00u32.into_safe_cast());

Required Methods§

Source

fn into_safe_cast(self) -> T

Convert self into a T. This operation is guaranteed to be lossless.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl<S, T> IntoSafeCast<T> for S
where T: FromSafeCast<S>,

Reverse operation for types implementing FromSafeCast.