Struct powerfmt::smart_display::FormatterOptions

source ·
pub struct FormatterOptions { /* private fields */ }
Expand description

Configuration for formatting.

This struct is obtained from a Formatter. It provides the same functionality as that of a reference to a Formatter. However, it is not possible to construct a Formatter, which is necessary for some use cases of SmartDisplay. FormatterOptions implements Default and has builder methods to alleviate this.

Implementations§

source§

impl FormatterOptions

source

pub fn with_fill(&mut self, c: char) -> &mut Self

Sets the fill character to use whenever there is alignment.

source

pub fn with_sign_plus(&mut self, b: bool) -> &mut Self

Set whether the + flag is specified.

source

pub fn with_sign_minus(&mut self, b: bool) -> &mut Self

Set whether the - flag is specified.

source

pub fn with_align(&mut self, align: Option<Alignment>) -> &mut Self

Set the flag indicating what form of alignment is requested, if any.

source

pub fn with_width(&mut self, width: Option<usize>) -> &mut Self

Set the optional integer width that the output should be.

source

pub fn with_precision(&mut self, precision: Option<usize>) -> &mut Self

Set the optional precision for numeric types. Alternatively, the maximum width for string types.

source

pub fn with_alternate(&mut self, b: bool) -> &mut Self

Set whether the # flag is specified.

source

pub fn with_sign_aware_zero_pad(&mut self, b: bool) -> &mut Self

Set whether the 0 flag is specified.

source§

impl FormatterOptions

source

pub const fn fill(&self) -> char

Character used as ‘fill’ whenever there is alignment.

source

pub const fn align(&self) -> Option<Alignment>

Flag indicating what form of alignment was requested.

source

pub const fn width(&self) -> Option<usize>

Optionally specified integer width that the output should be.

source

pub const fn precision(&self) -> Option<usize>

Optionally specified precision for numeric types. Alternatively, the maximum width for string types.

source

pub const fn sign_plus(&self) -> bool

Determines if the + flag was specified.

source

pub const fn sign_minus(&self) -> bool

Determines if the - flag was specified.

source

pub const fn alternate(&self) -> bool

Determines if the # flag was specified.

source

pub const fn sign_aware_zero_pad(&self) -> bool

Determines if the 0 flag was specified.

Trait Implementations§

source§

impl Clone for FormatterOptions

source§

fn clone(&self) -> FormatterOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for FormatterOptions

source§

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

Formats the value using the given formatter. Read more
source§

impl Default for FormatterOptions

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl From<&Formatter<'_>> for FormatterOptions

source§

fn from(value: &Formatter<'_>) -> Self

Converts to this type from the input type.
source§

impl From<&mut Formatter<'_>> for FormatterOptions

source§

fn from(value: &mut Formatter<'_>) -> Self

Converts to this type from the input type.
source§

impl Copy for FormatterOptions

Auto Trait Implementations§

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

§

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

§

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.