Skip to main content

ToUsize

Trait ToUsize 

Source
pub trait ToUsize {
    // Required method
    fn to_usize(&self) -> usize;
}
Expand description

Helper trait to convert numbers to usize.

By default, usize implements From<u8> and From<u16> but not From<u32> and From<u64> because that would be invalid on some platforms. This trait implements the conversion for platforms with 32 and 64 bits pointer platforms

Required Methods§

Source

fn to_usize(&self) -> usize

converts self to usize

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl ToUsize for u8

Source§

fn to_usize(&self) -> usize

Source§

impl ToUsize for u16

Source§

fn to_usize(&self) -> usize

Source§

impl ToUsize for u32

Available on 32-bit or 64-bit only.
Source§

fn to_usize(&self) -> usize

Source§

impl ToUsize for u64

Available on 64-bit only.
Source§

fn to_usize(&self) -> usize

Source§

impl ToUsize for usize

Source§

fn to_usize(&self) -> usize

Implementors§