Skip to main content

Integer

Trait Integer 

Source
pub(crate) trait Integer: Sized {
    const MAX_NUM_DIGITS: u8;
    const ZERO: Self;

    // Required methods
    fn push_digit(self, digit: u8) -> Self;
    fn checked_push_digit(self, digit: u8) -> Option<Self>;
}
Available on crate feature parsing only.
Expand description

Marker trait for integer types.

Required Associated Constants§

Source

const MAX_NUM_DIGITS: u8

The maximum number of digits that this type can have.

Source

const ZERO: Self

The zero value for this type.

Required Methods§

Source

fn push_digit(self, digit: u8) -> Self

Push a digit onto the end of this integer, assuming no overflow.

This is equivalent to self * 10 + digit.

Source

fn checked_push_digit(self, digit: u8) -> Option<Self>

Push a digit onto the end of this integer, returning None on overflow.

This is equivalent to self.checked_mul(10)?.checked_add(digit).

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Integer for u8

Source§

const MAX_NUM_DIGITS: u8

Source§

const ZERO: Self = 0

Source§

fn push_digit(self, digit: u8) -> Self

Source§

fn checked_push_digit(self, digit: u8) -> Option<Self>

Source§

impl Integer for u16

Source§

const MAX_NUM_DIGITS: u8

Source§

const ZERO: Self = 0

Source§

fn push_digit(self, digit: u8) -> Self

Source§

fn checked_push_digit(self, digit: u8) -> Option<Self>

Source§

impl Integer for u32

Source§

const MAX_NUM_DIGITS: u8

Source§

const ZERO: Self = 0

Source§

fn push_digit(self, digit: u8) -> Self

Source§

fn checked_push_digit(self, digit: u8) -> Option<Self>

Source§

impl Integer for u128

Source§

const MAX_NUM_DIGITS: u8

Source§

const ZERO: Self = 0

Source§

fn push_digit(self, digit: u8) -> Self

Source§

fn checked_push_digit(self, digit: u8) -> Option<Self>

Implementors§