Skip to main content Skip to main content
Pigweed's logo Pigweed
code_xml
  1. Home
  2. Reference
  3. Rust
  4. pw_kernel
  5. pw_cast
  6. CastFrom

CastFrom

Trait CastFrom 

Source
pub trait CastFrom<T> {
    // Required method
    fn cast_from(t: T) -> Self;
}
Expand description

Like [From], but supporting target-specific casts.

[From] does not support casts which are not valid on all targets (such as u32 to usize, which is not valid on 16-bit platforms). CastFrom, by contrast, supports all conversions which are valid on a given target. As a consequence, uses of CastFrom may not be portable to all targets.

Like [From], CastFrom only supports lossless casts.

Required Methods§

Source

fn cast_from(t: T) -> Self

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl CastFrom<bool> for usize

Source§

fn cast_from(t: bool) -> usize

Source§

impl CastFrom<u8> for u16

Source§

fn cast_from(t: u8) -> u16

Source§

impl CastFrom<u8> for usize

Source§

fn cast_from(t: u8) -> usize

Source§

impl CastFrom<u16> for u32

Source§

fn cast_from(t: u16) -> u32

Source§

impl CastFrom<u16> for usize

Source§

fn cast_from(t: u16) -> usize

Source§

impl CastFrom<u32> for u64

Source§

fn cast_from(t: u32) -> u64

Source§

impl CastFrom<u32> for usize

Source§

fn cast_from(t: u32) -> usize

Source§

impl CastFrom<usize> for u32

Source§

fn cast_from(t: usize) -> u32

Source§

impl CastFrom<usize> for u64

Source§

fn cast_from(t: usize) -> u64

Implementors§