Trait tstr::ToUint[][src]

pub trait ToUint: Sized {
    const USIZE: usize;
    const U128: u128;
    fn to_usize(&self) -> usize { ... }
fn to_u128(&self) -> u128 { ... } }
Expand description

Converts a TStr to unsigned integers.

Example

use tstr::{ToUint, TS, ts};

type Zero = TS!(0);
type N8   = TS!(8);
type N13  = TS!(13);
type N15  = TS!(0xF);
type N16  = TS!(0b10000);

assert_eq!(Zero::USIZE, 0);
assert_eq!(N8::USIZE, 8);
assert_eq!(N13::USIZE, 13);
assert_eq!(N15::USIZE, 15);
assert_eq!(N16::USIZE, 16);

assert_eq!(ts!(0).to_u128(), 0);
assert_eq!(ts!(8).to_u128(), 8);
assert_eq!(ts!(13).to_u128(), 13);
assert_eq!(ts!(0xF).to_u128(), 15);
assert_eq!(ts!(0b10000).to_u128(), 16);

Associated Constants

The usize value of the type.

By default this value is a saturated cast from Self::U128.

The u128 value of the type.

Provided methods

Gets the usize value of this type

By default this value is a saturated cast from Self::U128.

Gets the u128 value of this type

Implementors