dynfmt

Struct ArgumentSpec

Source
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>

Source

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).

Source

pub fn with_position(self, position: Position<'a>) -> Self

Sets the argument position. Defaults to Position::Auto.

Source

pub fn with_format(self, format: FormatType) -> Self

Sets the formatting type. Defaults to FormatType::Display.

Source

pub fn with_alternate(self, alternate: bool) -> Self

Switch the formatter to alternate mode.

Source

pub fn with_sign(self, sign: bool) -> Self

Always print a sign characters in front of numbers.

Source

pub fn with_zeros(self, pad_zero: bool) -> Self

Activate sign-aware zero padding.

Source

pub fn with_fill(self, fill_char: char) -> Self

Set the fill character. Defaults to ' ' (a space).

Source

pub fn with_alignment(self, alignment: Alignment) -> Self

Set alignment within the width of this format. Defaults to Alignment::Right.

Source

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.

Source

pub fn with_precision(self, precision: Option<Count<'a>>) -> Self

Set the precision for floating point values. Defaults to arbitrary precision.

Source

pub fn start(&self) -> usize

The start index of this specification in the format string.

Source

pub fn end(&self) -> usize

The end index of this specification in the format string.

Trait Implementations§

Source§

impl<'a> Debug for ArgumentSpec<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for ArgumentSpec<'a>

§

impl<'a> RefUnwindSafe for ArgumentSpec<'a>

§

impl<'a> Send for ArgumentSpec<'a>

§

impl<'a> Sync for ArgumentSpec<'a>

§

impl<'a> Unpin for ArgumentSpec<'a>

§

impl<'a> UnwindSafe for ArgumentSpec<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.