pub struct ArgumentSpec<'a> { /* private fields */ }Expand description
The format specification for a single argument in the format string, created by
Format::iter_args.
The argument spec may borrow data from the format string, e.g. when referring to named arguments in the argument list.
Implementations§
Source§impl<'a> ArgumentSpec<'a>
impl<'a> ArgumentSpec<'a>
Sourcepub fn new(start: usize, end: usize) -> Self
pub fn new(start: usize, end: usize) -> Self
Creates a new argument specification with default values.
The start and end parameters denote the exclusive range of this specification in the
format string. E.g. for a format string "{}", the range is [0, 2).
Sourcepub fn with_position(self, position: Position<'a>) -> Self
pub fn with_position(self, position: Position<'a>) -> Self
Sets the argument position. Defaults to Position::Auto.
Sourcepub fn with_format(self, format: FormatType) -> Self
pub fn with_format(self, format: FormatType) -> Self
Sets the formatting type. Defaults to FormatType::Display.
Sourcepub fn with_alternate(self, alternate: bool) -> Self
pub fn with_alternate(self, alternate: bool) -> Self
Switch the formatter to alternate mode.
Sourcepub fn with_zeros(self, pad_zero: bool) -> Self
pub fn with_zeros(self, pad_zero: bool) -> Self
Activate sign-aware zero padding.
Sourcepub fn with_fill(self, fill_char: char) -> Self
pub fn with_fill(self, fill_char: char) -> Self
Set the fill character. Defaults to ' ' (a space).
Sourcepub fn with_alignment(self, alignment: Alignment) -> Self
pub fn with_alignment(self, alignment: Alignment) -> Self
Set alignment within the width of this format. Defaults to Alignment::Right.
Sourcepub fn with_width(self, width: Option<Count<'a>>) -> Self
pub fn with_width(self, width: Option<Count<'a>>) -> Self
Set a minimum width for this argument. Defaults to None.
If the formatted argument is smaller than the threshold, the argument is padded with the
fill character. If the argument is numeric and with_zeros is specified, it is padded with
zeros instead.
Sourcepub fn with_precision(self, precision: Option<Count<'a>>) -> Self
pub fn with_precision(self, precision: Option<Count<'a>>) -> Self
Set the precision for floating point values. Defaults to arbitrary precision.