Trait LowerHex
pub trait LowerHex: PointeeSized
x formatting.
The LowerHex trait should format its output as a number in hexadecimal, with a through f
in lower case.
For primitive signed integers (i8 to i128, and isize),
negative values are formatted as the two’s complement representation.
The alternate flag, #, adds a 0x in front of the output.
For more information on formatters, see the module-level documentation.
Examples
Basic usage with i32:
let y = 42; // 42 is '2a' in hex
assert_eq!;
assert_eq!;
assert_eq!;
Implementing LowerHex on a type:
use fmt;
;
let l = Length;
assert_eq!;
assert_eq!;
Required Methods
fn fmt(&self, f: &mut Formatter<'_>) -> ResultFormats the value using the given formatter.
Errors
This function should return
Errif, and only if, the providedFormatterreturnsErr. String formatting is considered an infallible operation; this function only returns aResultbecause writing to the underlying stream might fail and it must provide a way to propagate the fact that an error has occurred back up the stack.
Implementors
impl LowerHex for i128impl LowerHex for i16impl LowerHex for i32impl LowerHex for i64impl LowerHex for i8impl LowerHex for isizeimpl LowerHex for u128impl LowerHex for u16impl LowerHex for u32impl LowerHex for u64impl LowerHex for u8impl LowerHex for usizeimpl<T> LowerHex for NonZero<T> where T: ZeroablePrimitive + LowerHex,impl<T: LowerHex> LowerHex for Saturating<T>impl<T: LowerHex> LowerHex for Wrapping<T>impl<T: PointeeSized + LowerHex> LowerHex for &Timpl<T: PointeeSized + LowerHex> LowerHex for &mut T