Skip to main content

ToUSize

Trait ToUSize 

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

Trait defining instance method to_usize() : usize that provides a no-cost or low-cost conversion into usize.

It is expected that the implementing type “is-a” usize in a logical manner.

§Additional Implementations on Foreign Types

§Built-in Types

If the feature "implement-ToUSize-for-built_ins" is defined (as it is by "default"), then this is also implemented for the following type(s):

  • usize;
  • u8;
  • u16 - if architecture is 16+ bits;
  • u32 - if architecture is 32+ bits;
  • u64 - if architecture is 64+ bits;
  • u128 - if architecture is 128+ bits;

Required Methods§

Source

fn to_usize(&self) -> 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

Source§

fn to_usize(&self) -> usize

Source§

impl ToUSize for u64

Source§

fn to_usize(&self) -> usize

Source§

impl ToUSize for usize

Source§

fn to_usize(&self) -> usize

Source§

impl<T: ToUSize + ?Sized> ToUSize for Box<T>

Available on non-crate feature nostd only.
Source§

fn to_usize(&self) -> usize

Source§

impl<T: ToUSize + ?Sized> ToUSize for Rc<T>

Available on non-crate feature nostd only.
Source§

fn to_usize(&self) -> usize

Implementors§