pub trait FormatArgument {
// Required methods
fn supports_format(&self, specifier: &Specifier) -> bool;
fn fmt_display(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_octal(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_binary(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result;
fn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result;
// Provided method
fn to_usize(&self) -> Result<usize, ()> { ... }
}Expand description
A type that indicates whether its value supports a specific format, and provides formatting functions that correspond to different format types.
Required Methods§
Sourcefn supports_format(&self, specifier: &Specifier) -> bool
fn supports_format(&self, specifier: &Specifier) -> bool
Returns true if self can be formatted using the given specifier.
Sourcefn fmt_display(&self, f: &mut Formatter<'_>) -> Result
fn fmt_display(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Display.
Sourcefn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
fn fmt_debug(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Debug.
Sourcefn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
fn fmt_octal(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Octal.
Sourcefn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerHex.
Sourcefn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_hex(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperHex.
Sourcefn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
fn fmt_binary(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::Binary.
Sourcefn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_lower_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::LowerExp.
Sourcefn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
fn fmt_upper_exp(&self, f: &mut Formatter<'_>) -> Result
Formats the value the way it would be formatted if it implemented std::fmt::UpperExp.
Provided Methods§
Sourcefn to_usize(&self) -> Result<usize, ()>
fn to_usize(&self) -> Result<usize, ()>
Performs a type conversion into usize that might fail. Like TryInto<usize>, but does not
consume self. The parser uses this to support formats whose width or precision use “dollar
syntax”. For more information about these, see std::fmt. The default implementation always
returns an error.