FormattingOptions in std::fmt - Rust (original) (raw)
Struct FormattingOptions
pub struct FormattingOptions { /* private fields */ }
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Expand description
Options for formatting.
FormattingOptions
is a Formatter without an attached Write trait. It is mainly used to construct Formatter
instances.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Construct a new FormatterBuilder
with the supplied Write
trait object for output that is equivalent to the {}
formatting specifier:
- no flags,
- filled with spaces,
- no alignment,
- no width,
- no precision, and
- no DebugAsHex output mode.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets 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
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets or unsets the 0
flag.
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
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets or unsets the #
flag.
This flag indicates that the “alternate” form of printing should be used. The alternate forms are:
- Debug : pretty-print the Debug formatting (adds linebreaks and indentation)
- LowerHex as well as UpperHex - precedes the argument with a
0x
- Octal - precedes the argument with a
0b
- Binary - precedes the argument with a
0o
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets 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.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets 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.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets 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.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Sets 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.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Specifies whether the Debug trait should use lower-/upper-case hexadecimal or normal integers
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current sign (the +
or the -
flag).
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current 0
flag.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current #
flag.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current fill character.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current alignment.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current width.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current precision.
🔬This is a nightly-only experimental API. (formatting_options
#118117)
Returns the current precision.
🔬This is a nightly-only experimental API. (formatting_options
#118117)