Expand description
A generalized version of format_args, that allows you to format into arbitrary types, instead of just strings.
For examples, see the examples subdirectory. color.rs provides a simple motivation.
To get started, implement CustomFormatter. For types with a single canonical way to format,
implement CustomFormatter directly on the type with Output = Self. For types with multiple
different formatting strategies (such as Debug and Display for strings), implement
CustomFormatter on a marker type instead.
Then, implement Format<F> on types that can be formatted into your custom formatter.
Finally, you can use the provided macro, custom_format!, in a similar manner to format, to
create instances of the type.
Macros§
- __
custom_ format_ args_ internal - custom_
format - Create any type that is the output of a
CustomFormatter, from a formatting string. - custom_
format_ args - Create an
Argumentsfrom a formatting string.
Structs§
- Argument
- Represents a single formatting argument.
- Arguments
- A collection of format arguments. Implements
Iterator<Item = (&'static str, Option<Argument<'a, F>>). Construct this usingcustom_format_args. - Debug
Formatter - An example formatter. Can format anything with a Debug implementation. Formats into a String.
- Display
Formatter - An example formatter. Can format anything with a Display implementation. Formats into a String.
Traits§
- Custom
Formatter - A custom formatting strategy.
- Format
Functions§
- custom_
format - Format into a type, using the given formatting strategy.
- custom_
format_ infer - Format into a T, possibly inferring type from surroundings.