Trait nom::lib::std::fmt::Octal1.0.0[][src]

pub trait Octal {
    fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description

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

Formats the value using the given formatter.

Implementations on Foreign Types

Implementors

impl<'a, I> Octal for Format<'a, I> where
    I: Iterator,
    I::Item: Octal

impl Octal for AtFlags

impl Octal for OFlag

impl Octal for SealFlag

impl Octal for FdFlag

impl Octal for MsFlags

impl Octal for MntFlags

impl Octal for MQ_OFlag

impl Octal for FdFlag

impl Octal for PollFlags

impl Octal for CloneFlags

impl Octal for EpollFlags

impl Octal for EfdFlags

impl Octal for ProtFlags

impl Octal for MapFlags

impl Octal for MsFlags

impl Octal for Persona

impl Octal for Options

impl Octal for SaFlags

impl Octal for SfdFlags

impl Octal for SockFlag

impl Octal for MsgFlags

impl Octal for SFlag

impl Octal for Mode

impl Octal for FsFlags

impl Octal for InputFlags

impl Octal for LocalFlags

impl Octal for InitFlags

impl Octal for TimerFlags

impl<'a, Color: Color, T: Octal> Octal for FgColorDisplay<'a, Color, T>

impl<'a, Color: Color, T: Octal> Octal for BgColorDisplay<'a, Color, T>

impl<'a, Color: DynColor, T: Octal> Octal for FgDynColorDisplay<'a, Color, T>

impl<'a, Color: DynColor, T: Octal> Octal for BgDynColorDisplay<'a, Color, T>

impl<'a, Fg: Color, Bg: Color, T: Octal> Octal for ComboColorDisplay<'a, Fg, Bg, T>

impl<T: Octal> Octal for Styled<T>

impl<'a, T: Octal> Octal for BoldDisplay<'a, T>

impl<'a, T: Octal> Octal for DimDisplay<'a, T>

impl<'a, T: Octal> Octal for ItalicDisplay<'a, T>

impl<'a, T: Octal> Octal for UnderlineDisplay<'a, T>

impl<'a, T: Octal> Octal for BlinkDisplay<'a, T>

impl<'a, T: Octal> Octal for BlinkFastDisplay<'a, T>

impl<'a, T: Octal> Octal for ReversedDisplay<'a, T>

impl<'a, T: Octal> Octal for HiddenDisplay<'a, T>

impl<'a, T: Octal> Octal for StrikeThroughDisplay<'a, T>

impl<'a, In, Out, F> Octal for SupportsColorsDisplay<'a, In, Out, F> where
    In: Octal,
    Out: Octal,
    F: Fn(&'a In) -> Out,