Trait Binary
pub trait Binary: PointeeSized
b formatting.
The Binary trait should format its output as a number in binary.
For primitive signed integers (i8 to i128, and isize),
negative values are formatted as the two’s complement representation.
The alternate flag, #, adds a 0b in front of the output.
For more information on formatters, see the module-level documentation.
Examples
Basic usage with [i32]:
let x = 42; // 42 is '101010' in binary
assert_eq!;
assert_eq!;
assert_eq!;
Implementing Binary 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 Binary for i128impl Binary for i16impl Binary for i32impl Binary for i64impl Binary for i8impl Binary for isizeimpl Binary for u128impl Binary for u16impl Binary for u32impl Binary for u64impl Binary for u8impl Binary for usizeimpl<T> Binary for NonZero<T> where T: ZeroablePrimitive + Binary,impl<T: Binary> Binary for Saturating<T>impl<T: Binary> Binary for Wrapping<T>impl<T: PointeeSized + Binary> Binary for &Timpl<T: PointeeSized + Binary> Binary for &mut T