pub struct FormatSpec {
pub fill: Option<char>,
pub align: Option<Align>,
pub sign: Option<Sign>,
pub alternate: bool,
pub zero: bool,
pub width: Option<usize>,
pub precision: Option<usize>,
pub ty: FmtType,
}Expand description
A complete format specification for dynamic formatting.
FormatSpec represents all the components of a format specification that can appear
between the colons in a format string: "{:<5.2}". It controls how values are formatted
including alignment, padding, width, precision, and type-specific formatting.
§Format String Components
A format specification in a string typically looks like:
:[fill][align][sign][#][0][width][.precision][type]
Fields§
§fill: Option<char>The fill character to use for padding.
If None, spaces will be used for padding.
align: Option<Align>The alignment of the formatted value within the field.
If None, the default alignment (typically right for numbers, left for text) will be used.
sign: Option<Sign>The sign display option for numeric values.
If None, signs will only be shown for negative numbers.
alternate: boolWhether to use alternate formatting.
For example, adding 0x prefix to hexadecimal numbers or always showing the decimal point.
zero: boolWhether to pad with zeros instead of the fill character.
This is typically used for numeric types to ensure a minimum number of digits.
width: Option<usize>The minimum width of the formatted field.
If the formatted value is shorter than this width, it will be padded according to the alignment.
precision: Option<usize>The precision for floating-point numbers or maximum length for strings.
ty: FmtTypeThe format type specification.
Implementations§
Source§impl FormatSpec
impl FormatSpec
Trait Implementations§
Source§impl Clone for FormatSpec
impl Clone for FormatSpec
Source§fn clone(&self) -> FormatSpec
fn clone(&self) -> FormatSpec
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more