Struct FormattingOptions
struct FormattingOptions { ... }
Options for formatting.
FormattingOptions is a Formatter without an attached Write trait.
It is mainly used to construct Formatter instances.
Implementations
impl FormattingOptions
const fn new() -> SelfConstruct a new
FormatterBuilderwith the suppliedWritetrait object for output that is equivalent to the{}formatting specifier:- no flags,
- filled with spaces,
- no alignment,
- no width,
- no precision, and
- no
DebugAsHexoutput mode.
const fn sign(self: &mut Self, sign: Option<Sign>) -> &mut SelfSets or removes the sign (the
+or the-flag).+: This is intended for numeric types and indicates that the sign should always be printed. By default only the negative sign of signed values is printed, and the sign of positive or unsigned values is omitted. This flag indicates that the correct sign (+ or -) should always be printed.-: Currently not used
const fn sign_aware_zero_pad(self: &mut Self, sign_aware_zero_pad: bool) -> &mut SelfSets or unsets the
0flag.This is used to indicate for integer formats that the padding to width should both be done with a 0 character as well as be sign-aware
const fn alternate(self: &mut Self, alternate: bool) -> &mut SelfSets or unsets the
#flag.This flag indicates that the "alternate" form of printing should be used. The alternate forms are:
const fn fill(self: &mut Self, fill: char) -> &mut SelfSets the fill character.
The optional fill character and alignment is provided normally in conjunction with the width parameter. This indicates that if the value being formatted is smaller than width some extra characters will be printed around it.
const fn align(self: &mut Self, align: Option<Alignment>) -> &mut SelfSets or removes the alignment.
The alignment specifies how the value being formatted should be positioned if it is smaller than the width of the formatter.
const fn width(self: &mut Self, width: Option<u16>) -> &mut SelfSets or removes the width.
This is a parameter for the “minimum width” that the format should take up. If the value’s string does not fill up this many characters, then the padding specified by
FormattingOptions::fill/FormattingOptions::alignwill be used to take up the required space.const fn precision(self: &mut Self, precision: Option<u16>) -> &mut SelfSets or removes the precision.
- For non-numeric types, this can be considered a “maximum width”. If the resulting string is longer than this width, then it is truncated down to this many characters and that truncated value is emitted with proper fill, alignment and width if those parameters are set.
- For integral types, this is ignored.
- For floating-point types, this indicates how many digits after the decimal point should be printed.
const fn debug_as_hex(self: &mut Self, debug_as_hex: Option<DebugAsHex>) -> &mut SelfSpecifies whether the
Debugtrait should use lower-/upper-case hexadecimal or normal integersconst fn get_sign(self: &Self) -> Option<Sign>Returns the current sign (the
+or the-flag).const fn get_sign_aware_zero_pad(self: &Self) -> boolReturns the current
0flag.const fn get_alternate(self: &Self) -> boolReturns the current
#flag.const fn get_fill(self: &Self) -> charReturns the current fill character.
const fn get_align(self: &Self) -> Option<Alignment>Returns the current alignment.
const fn get_width(self: &Self) -> Option<u16>Returns the current width.
const fn get_precision(self: &Self) -> Option<u16>Returns the current precision.
const fn get_debug_as_hex(self: &Self) -> Option<DebugAsHex>Returns the current precision.
const fn create_formatter<'a>(self: Self, write: &'a mut dyn Write + 'a) -> Formatter<'a>Creates a
Formatterthat writes its output to the givenWritetrait.You may alternatively use [
Formatter::new()].
impl Clone for FormattingOptions
fn clone(self: &Self) -> FormattingOptions
impl Copy for FormattingOptions
impl Debug for FormattingOptions
fn fmt(self: &Self, f: &mut $crate::fmt::Formatter<'_>) -> $crate::fmt::Result
impl Default for FormattingOptions
fn default() -> SelfSame as [
FormattingOptions::new()].
impl Eq for FormattingOptions
impl Freeze for FormattingOptions
impl PartialEq for FormattingOptions
fn eq(self: &Self, other: &FormattingOptions) -> bool
impl RefUnwindSafe for FormattingOptions
impl Send for FormattingOptions
impl StructuralPartialEq for FormattingOptions
impl Sync for FormattingOptions
impl Unpin for FormattingOptions
impl UnwindSafe for FormattingOptions
impl<T> Any for FormattingOptions
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for FormattingOptions
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for FormattingOptions
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> CloneToUninit for FormattingOptions
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> From for FormattingOptions
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for FormattingOptions
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for FormattingOptions
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for FormattingOptions
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>