Skip to main content

ToUsize

Trait ToUsize 

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

Infallibly convert a value into usize.

Implementations exist only when the conversion is guaranteed not to lose information under the selected min-usize-* portability contract.

use usize_conv::ToUsize;

let x: u16 = 5;
assert_eq!(x.to_usize(), 5usize);

Required Methods§

Source

fn to_usize(self) -> usize

Implementations on Foreign Types§

Source§

impl ToUsize for u8

Source§

impl ToUsize for u16

Source§

impl ToUsize for u32

Source§

impl ToUsize for u64

Source§

impl ToUsize for usize

Available on crate feature min-usize-32 only.
Source§

impl ToUsize for NonZeroU8

Source§

impl ToUsize for NonZeroU16

Source§

impl ToUsize for NonZeroU32

Source§

impl ToUsize for NonZeroU64

Implementors§