Trait GenericRadix

Source
#[doc(hidden)] unsafe trait GenericRadix: Sized {
    const BASE: u8;
    const PREFIX: &'static str;

    // Required method
    fn digit(x: u8) -> u8;

    // Provided method
    fn fmt_int<T: DisplayInt>(&self, x: T, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

A type that represents a specific radix

§Safety

digit must return an ASCII character.

Required Associated Constants§

Source

const BASE: u8

The number of digits.

Source

const PREFIX: &'static str

A radix-specific prefix string.

Required Methods§

Source

fn digit(x: u8) -> u8

Converts an integer to corresponding radix digit.

Provided Methods§

Source

fn fmt_int<T: DisplayInt>(&self, x: T, f: &mut Formatter<'_>) -> Result

Format an integer using the radix using a formatter.

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.

Implementors§

Source§

impl GenericRadix for Binary

Source§

const BASE: u8 = 2u8

Source§

const PREFIX: &'static str = "0b"

Source§

impl GenericRadix for LowerHex

Source§

const BASE: u8 = 16u8

Source§

const PREFIX: &'static str = "0x"

Source§

impl GenericRadix for Octal

Source§

const BASE: u8 = 8u8

Source§

const PREFIX: &'static str = "0o"

Source§

impl GenericRadix for UpperHex

Source§

const BASE: u8 = 16u8

Source§

const PREFIX: &'static str = "0x"