Struct std::fmt::Formatter

pub struct Formatter<'self> {
    flags: uint,
    fill: char,
    align: Alignment,
    width: Option<uint>,
    precision: Option<uint>,
    buf: &'self mut Writer,
    priv curarg: VecIterator<'self, Argument<'self>>,
    priv args: &'self [Argument<'self>],
}

A struct to represent both where to emit formatting strings to and how they should be formatted. A mutable version of this is passed to all formatting traits.

Methods

impl<'self> Formatter<'self>

fn pad_integral(&mut self, s: &[u8], alternate_prefix: &str, positive: bool)

Performs the correct padding for an integer which has already been emitted into a byte-array. The byte-array should not contain the sign for the integer, that will be added by this method.

Arguments

* s - the byte array that the number has been formatted into
* alternate_prefix - if the '#' character (FlagAlternate) is
  provided, this is the prefix to put in front of the number.
  Currently this is 0x/0o/0b/etc.
* positive - whether the original integer was positive or not.

This function will correctly account for the flags provided as well as the minimum width. It will not take precision into account.

fn pad(&mut self, s: &str)

This function takes a string slice and emits it to the internal buffer after applying the relevant formatting flags specified. The flags recognized for generic strings are:

  • width - the minimum width of what to emit
  • fill/align - what to emit and where to emit it if the string provided needs to be padded
  • precision - the maximum length to emit, the string is truncated if it is longer than this length

Notably this function ignored the flag parameters