Trait LowerHex
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: &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<T: PointeeSized + LowerHex> LowerHex for &Timpl<T: fmt::LowerHex> LowerHex for Saturating<T>impl LowerHex for u32impl<T: PointeeSized + LowerHex> LowerHex for &mut Timpl LowerHex for usizeimpl LowerHex for i32impl LowerHex for isizeimpl<T: fmt::LowerHex> LowerHex for Wrapping<T>impl LowerHex for u64impl LowerHex for u8impl<T> LowerHex for NonZero<T>impl LowerHex for i64impl LowerHex for i8impl LowerHex for u128impl LowerHex for u16