Module smart_display
Definition of SmartDisplay and its related items.
SmartDisplay is a trait that allows authors to provide additional information to both the
formatter and other users. This information is provided in the form of a metadata type. The only
required piece of metadata is the width of the value. This is before it is passed to the
formatter (i.e. it does not include any padding added by the formatter). Other information
can be stored in a custom metadata type as needed. This information may be made available to
downstream users, but it is not required.
This module contains the SmartDisplay and associated items.
Example
use fmt;
use FormatterExt as _;
use ;
// If you try to use `UserMetadata` in the `SmartDisplay` implementation, you will get a
// compiler error about a private type being used publicly. To avoid this, use this attribute to
// declare a private metadata type. You shouldn't need to worry about how this works, but be
// aware that any public fields or methods remain usable by downstream users.
// This attribute can be applied to `SmartDisplay` implementations. It will generate an
// implementation of `Display` that delegates to `SmartDisplay`, avoiding the need to write
// boilerplate.
let user = User ;
assert_eq!;
assert_eq!;
Structs
- FormatterOptions Configuration for formatting.
-
Metadata
Information used to format a value. This is returned by
SmartDisplay::metadata.
Traits
- SmartDisplay Format trait that allows authors to provide additional information.