Trait frame_support::dispatch::fmt::Octal 1.0.0[−][src]
o
formatting.
The Octal
trait should format its output as a number in base-8.
For primitive signed integers (i8
to i128
, and isize
),
negative values are formatted as the two’s complement representation.
The alternate flag, #
, adds a 0o
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 '52' in octal assert_eq!(format!("{:o}", x), "52"); assert_eq!(format!("{:#o}", x), "0o52"); assert_eq!(format!("{:o}", -16), "37777777760");
Implementing Octal
on a type:
use std::fmt; struct Length(i32); impl fmt::Octal for Length { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { let val = self.0; fmt::Octal::fmt(&val, f) // delegate to i32's implementation } } let l = Length(9); assert_eq!(format!("l as octal is: {:o}", l), "l as octal is: 11"); assert_eq!(format!("l as octal is: {:#06o}", l), "l as octal is: 0o0011");
Required methods
pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
[src][−]
Formats the value using the given formatter.
Implementations on Foreign Types
impl<'_, T> Octal for &'_ mut T where
T: Octal + ?Sized,
[src]
impl<'_, T> Octal for &'_ mut T where
T: Octal + ?Sized,
[src]impl<T> Octal for Wrapping<T> where
T: Octal,
[src]
impl<T> Octal for Wrapping<T> where
T: Octal,
[src]impl<'_, T> Octal for &'_ T where
T: Octal + ?Sized,
[src]
impl<'_, T> Octal for &'_ T where
T: Octal + ?Sized,
[src]impl<A> Octal for ArrayVec<A> where
A: Array,
<A as Array>::Item: Octal,
[src]
impl<A> Octal for ArrayVec<A> where
A: Array,
<A as Array>::Item: Octal,
[src]impl<'s, T> Octal for SliceVec<'s, T> where
T: Octal,
[src]
impl<'s, T> Octal for SliceVec<'s, T> where
T: Octal,
[src]impl<A> Octal for TinyVec<A> where
A: Array,
<A as Array>::Item: Octal,
[src]
impl<A> Octal for TinyVec<A> where
A: Array,
<A as Array>::Item: Octal,
[src]Implementors
impl<O, V> Octal for BitArray<O, V> where
O: BitOrder,
V: BitView,
impl<O, V> Octal for BitArray<O, V> where
O: BitOrder,
V: BitView,
impl<T> Octal for Domain<'_, T> where
T: BitStore,
impl<T> Octal for Domain<'_, T> where
T: BitStore,
impl<O, T> Octal for BitSlice<O, T> where
O: BitOrder,
T: BitStore,
impl<O, T> Octal for BitSlice<O, T> where
O: BitOrder,
T: BitStore,
impl<O, T> Octal for BitBox<O, T> where
O: BitOrder,
T: BitStore,
impl<O, T> Octal for BitBox<O, T> where
O: BitOrder,
T: BitStore,
impl<O, T> Octal for BitVec<O, T> where
O: BitOrder,
T: BitStore,
impl<O, T> Octal for BitVec<O, T> where
O: BitOrder,
T: BitStore,
impl<'a, T: Octal> Octal for StyledValue<'a, T>
impl<'a, T: Octal> Octal for StyledValue<'a, T>
impl<'a, I> Octal for Format<'a, I> where
I: Iterator,
I::Item: Octal,
impl<'a, I> Octal for Format<'a, I> where
I: Iterator,
I::Item: Octal,
impl<N, R: Dim, C: Dim, S> Octal for Matrix<N, R, C, S> where
N: Scalar + Octal,
S: Storage<N, R, C>,
DefaultAllocator: Allocator<usize, R, C>,
impl<N, R: Dim, C: Dim, S> Octal for Matrix<N, R, C, S> where
N: Scalar + Octal,
S: Storage<N, R, C>,
DefaultAllocator: Allocator<usize, R, C>,
impl Octal for BigInt
impl Octal for BigInt
impl Octal for BigUint
impl Octal for BigUint
impl<T> Octal for Complex<T> where
T: Octal + Num + PartialOrd + Clone,
impl<T> Octal for Complex<T> where
T: Octal + Num + PartialOrd + Clone,
impl Octal for Protection
impl Octal for Protection
impl<A: Array> Octal for ArrayVec<A> where
A::Item: Octal,
impl<A: Array> Octal for ArrayVec<A> where
A::Item: Octal,
impl<'s, T> Octal for SliceVec<'s, T> where
T: Octal,
impl<'s, T> Octal for SliceVec<'s, T> where
T: Octal,
impl<A: Array> Octal for TinyVec<A> where
A::Item: Octal,
impl<A: Array> Octal for TinyVec<A> where
A::Item: Octal,
impl<T: Binary + Octal> Octal for FmtBinary<T>
impl<T: Binary + Octal> Octal for FmtBinary<T>
impl<T: Display + Octal> Octal for FmtDisplay<T>
impl<T: Display + Octal> Octal for FmtDisplay<T>
impl<T: LowerExp + Octal> Octal for FmtLowerExp<T>
impl<T: LowerExp + Octal> Octal for FmtLowerExp<T>
impl<T: LowerHex + Octal> Octal for FmtLowerHex<T>
impl<T: LowerHex + Octal> Octal for FmtLowerHex<T>
impl<T: Octal> Octal for FmtOctal<T>
impl<T: Octal> Octal for FmtOctal<T>
impl<T: Pointer + Octal> Octal for FmtPointer<T>
impl<T: Pointer + Octal> Octal for FmtPointer<T>
impl<T: UpperExp + Octal> Octal for FmtUpperExp<T>
impl<T: UpperExp + Octal> Octal for FmtUpperExp<T>
impl<T: UpperHex + Octal> Octal for FmtUpperHex<T>
impl<T: UpperHex + Octal> Octal for FmtUpperHex<T>