pub trait Display {
// Required method
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>;
}
Expand description
Format trait for an empty format, {}
.
Implementing this trait for a type will automatically implement the
ToString
trait for the type, allowing the usage
of the .to_string()
method. Prefer implementing
the Display
trait for a type, rather than ToString
.
Display
is similar to Debug
, but Display
is for user-facing
output, and so cannot be derived.
For more information on formatters, see the module-level documentation.
§Internationalization
Because a type can only have one Display
implementation, it is often preferable
to only implement Display
when there is a single most “obvious” way that
values can be formatted as text. This could mean formatting according to the
“invariant” culture and “undefined” locale, or it could mean that the type
display is designed for a specific culture/locale, such as developer logs.
If not all values have a justifiably canonical textual format or if you want
to support alternative formats not covered by the standard set of possible
formatting traits, the most flexible approach is display adapters: methods
like str::escape_default
or Path::display
which create a wrapper
implementing Display
to output the specific display format.
§Examples
Implementing Display
on a type:
use std::fmt;
struct Point {
x: i32,
y: i32,
}
impl fmt::Display for Point {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
let origin = Point { x: 0, y: 0 };
assert_eq!(format!("The origin is: {origin}"), "The origin is: (0, 0)");
Required Methods§
1.0.0 · Sourcefn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>
Formats the value using the given formatter.
§Errors
This function should return Err
if, and only if, the provided Formatter
returns Err
.
String formatting is considered an infallible operation; this function only
returns a Result
because writing to the underlying stream might fail and it must
provide a way to propagate the fact that an error has occurred back up the stack.
§Examples
use std::fmt;
struct Position {
longitude: f32,
latitude: f32,
}
impl fmt::Display for Position {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({}, {})", self.longitude, self.latitude)
}
}
assert_eq!(
"(1.987, 2.983)",
format!("{}", Position { longitude: 1.987, latitude: 2.983, }),
);
Implementors§
impl Display for Tz
impl Display for clang_sys::Version
impl Display for codespan_reporting::files::Error
impl Display for gimli::read::Error
impl Display for globset::ErrorKind
impl Display for AdditionError
impl Display for CreationError
impl Display for RecordError
impl Display for SubtractionError
impl Display for httparse::Error
impl Display for humantime::date::Error
impl Display for humantime::duration::Error
impl Display for GetTimezoneError
impl Display for CodePointInversionListError
impl Display for CodePointInversionListAndStringListError
impl Display for icu_collections::codepointtrie::error::Error
impl Display for ParserError
impl Display for LocaleTransformError
impl Display for NormalizerError
impl Display for PropertiesError
impl Display for DataErrorKind
impl Display for ignore::Error
impl Display for IpNet
impl Display for libloading::error::Error
impl Display for InsertError
impl Display for matchit::error::MatchError
impl Display for nix::errno::consts::Errno
impl Display for Signal
impl Display for rand::distributions::bernoulli::BernoulliError
impl Display for WeightedError
impl Display for StartError
impl Display for Ast
Print a display representation of this Ast.
This does not preserve any of the original whitespace formatting that may have originally been present in the concrete syntax from which this Ast was generated.
This implementation uses constant stack space and heap space proportional
to the size of the Ast
.
impl Display for regex_syntax::ast::ErrorKind
impl Display for regex_syntax::error::Error
impl Display for regex_syntax::hir::ErrorKind
impl Display for rustls_pki_types::pem::Error
impl Display for rusty_fork::error::Error
impl Display for Segment
impl Display for serde_urlencoded::ser::Error
impl Display for QuoteError
impl Display for CollectionAllocErr
impl Display for StrSimError
impl Display for TinyStrError
impl Display for AnyDelimiterCodecError
impl Display for LinesCodecError
impl Display for Item
impl Display for toml_edit::ser::Error
impl Display for toml_edit::value::Value
impl Display for ucd_trie::owned::Error
impl Display for GraphemeClusterBreak
impl Display for SentenceBreak
impl Display for WordBreak
impl Display for winnow::error::ErrorKind
The Display implementation allows the std::error::Error
implementation
impl Display for StrContext
impl Display for StrContextValue
impl Display for BigEndian
impl Display for LittleEndian
impl Display for ZeroVecError
impl Display for rustmax::axum::extract::path::ErrorKind
impl Display for BytesRejection
impl Display for ExtensionRejection
impl Display for FailedToBufferBody
impl Display for FormRejection
impl Display for JsonRejection
impl Display for MatchedPathRejection
impl Display for PathRejection
impl Display for QueryRejection
impl Display for RawFormRejection
impl Display for RawPathParamsRejection
impl Display for StringRejection
impl Display for ParseAlphabetError
impl Display for DecodeError
impl Display for DecodeSliceError
impl Display for EncodeSliceError
impl Display for DeriveTrait
impl Display for Abi
impl Display for AliasVariation
impl Display for BindgenError
impl Display for EnumVariation
impl Display for FieldVisibilityKind
impl Display for Formatter
impl Display for MacroTypeVariation
impl Display for NonCopyUnionStyle
impl Display for RustEdition
impl Display for RoundingError
impl Display for Weekday
impl Display for ColorChoice
impl Display for ContextKind
impl Display for ContextValue
impl Display for rustmax::clap::error::ErrorKind
impl Display for MatchesError
impl Display for rustmax::crossbeam::channel::RecvTimeoutError
impl Display for rustmax::crossbeam::channel::TryRecvError
impl Display for rustmax::ctrlc::Error
impl Display for FromHexError
impl Display for rustmax::json5::Error
impl Display for rustmax::log::Level
impl Display for rustmax::log::LevelFilter
impl Display for rustmax::proc_macro2::TokenTree
Prints the token tree as a string that is supposed to be losslessly
convertible back into the same token tree (modulo spans), except for
possibly TokenTree::Group
s with Delimiter::None
delimiters and negative
numeric literals.
impl Display for rustmax::proc_macro::TokenTree
Prints the token tree as a string that is supposed to be losslessly convertible back
into the same token tree (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters and negative numeric literals.
Note: the exact form of the output is subject to change, e.g. there might
be changes in the whitespace used between tokens. Therefore, you should
not do any kind of simple substring matching on the output string (as
produced by to_string
) to implement a proc macro, because that matching
might stop working if such changes happen. Instead, you should work at the
TokenTree
level, e.g. matching against TokenTree::Ident
,
TokenTree::Punct
, or TokenTree::Literal
.
impl Display for TestCaseError
impl Display for rustmax::proptest::string::Error
impl Display for RngAlgorithm
impl Display for rustmax::rand::distr::BernoulliError
impl Display for rustmax::rand::distr::uniform::Error
impl Display for rustmax::rand::seq::WeightError
impl Display for rustmax::regex::Error
impl Display for ReadlineError
impl Display for AsciiChar
impl Display for Infallible
impl Display for VarError
impl Display for rustmax::std::io::ErrorKind
impl Display for IpAddr
impl Display for SocketAddr
impl Display for rustmax::std::sync::mpsc::RecvTimeoutError
impl Display for rustmax::std::sync::mpsc::TryRecvError
impl Display for LogicOperator
impl Display for MathOperator
impl Display for rustmax::tera::Value
impl Display for rustmax::tokio::sync::broadcast::error::RecvError
impl Display for rustmax::tokio::sync::broadcast::error::TryRecvError
impl Display for TryAcquireError
impl Display for rustmax::tokio::sync::mpsc::error::TryRecvError
impl Display for rustmax::tokio::sync::oneshot::error::TryRecvError
impl Display for rustmax::toml::Value
impl Display for rustmax::toml::value::Offset
impl Display for rustmax::url::ParseError
impl Display for SyntaxViolation
impl Display for BinaryError
impl Display for bool
impl Display for char
impl Display for f32
impl Display for f64
impl Display for i8
impl Display for i16
impl Display for i32
impl Display for i64
impl Display for i128
impl Display for isize
impl Display for !
impl Display for str
impl Display for u8
impl Display for u16
impl Display for u32
impl Display for u64
impl Display for u128
impl Display for usize
impl Display for aho_corasick::util::error::BuildError
impl Display for aho_corasick::util::error::MatchError
impl Display for aho_corasick::util::primitives::PatternIDError
impl Display for aho_corasick::util::primitives::StateIDError
impl Display for bstr::bstr::BStr
impl Display for BString
impl Display for bstr::ext_vec::FromUtf8Error
impl Display for bstr::utf8::Utf8Error
impl Display for chrono_tz::timezones::ParseError
impl Display for AsciiCharsIter<'_>
Format without a temporary string
use deunicode::AsciiChars;
format!("what's up {}", "🐶".ascii_chars());
impl Display for env_filter::parser::ParseError
impl Display for getrandom::error::Error
impl Display for getrandom::error::Error
impl Display for DwAccess
impl Display for DwAddr
impl Display for DwAt
impl Display for DwAte
impl Display for DwCc
impl Display for DwCfa
impl Display for DwChildren
impl Display for DwDefaulted
impl Display for DwDs
impl Display for DwDsc
impl Display for DwEhPe
impl Display for DwEnd
impl Display for DwForm
impl Display for DwId
impl Display for DwIdx
impl Display for DwInl
impl Display for DwLang
impl Display for DwLle
impl Display for DwLnct
impl Display for DwLne
impl Display for DwLns
impl Display for DwMacro
impl Display for DwOp
impl Display for DwOrd
impl Display for DwRle
impl Display for DwSect
impl Display for DwSectV2
impl Display for DwTag
impl Display for DwUt
impl Display for DwVirtuality
impl Display for DwVis
impl Display for glob::GlobError
impl Display for Pattern
Show the original glob pattern.
impl Display for PatternError
impl Display for Glob
impl Display for globset::Error
impl Display for globwalk::GlobError
impl Display for h2::error::Error
impl Display for h2::frame::reason::Reason
impl Display for UsizeTypeTooSmall
impl Display for http_body_util::limited::LengthLimitError
impl Display for InvalidChunkSize
impl Display for HttpDate
impl Display for httpdate::Error
impl Display for Rfc3339Timestamp
impl Display for FormattedDuration
impl Display for Duration
impl Display for humantime::wrapper::Timestamp
impl Display for hyper_util::client::legacy::client::Error
impl Display for InvalidNameError
impl Display for hyper_util::client::legacy::connect::dns::Name
impl Display for Other
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::other::subtag::Subtag
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::private::other::Subtag
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Private
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Extensions
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Fields
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::transform::key::Key
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Transform
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::transform::value::Value
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Attribute
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Attributes
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::unicode::key::Key
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Keywords
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for Unicode
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for icu_locid::extensions::unicode::value::Value
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for LanguageIdentifier
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for Locale
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for Language
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Region
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Script
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Variant
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for Variants
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
impl Display for MirroredPairedBracketDataTryFromError
impl Display for DataError
impl Display for FormattedHelloWorld<'_>
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for DataKey
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for DataLocale
This trait is implemented for compatibility with fmt!
.
To create a string, Writeable::write_to_string
is usually more efficient.
impl Display for DataRequest<'_>
impl Display for Errors
impl Display for indexmap::TryReserveError
impl Display for Ipv4Net
impl Display for Ipv6Net
impl Display for PrefixLenError
impl Display for ipnet::parser::AddrParseError
impl Display for native_tls::Error
impl Display for TimeSpec
impl Display for TimeVal
impl Display for Pid
impl Display for num_traits::ParseFloatError
impl Display for object::read::Error
impl Display for SectionIndex
impl Display for SymbolIndex
impl Display for Asn1GeneralizedTimeRef
impl Display for Asn1ObjectRef
impl Display for Asn1TimeRef
impl Display for BigNum
impl Display for BigNumRef
impl Display for openssl::error::Error
impl Display for ErrorStack
impl Display for openssl::ssl::error::Error
impl Display for OpensslString
impl Display for OpensslStringRef
impl Display for X509VerifyResult
impl Display for ReadError
impl Display for rand_core::error::Error
impl Display for regex_automata::dfa::onepass::BuildError
impl Display for regex_automata::hybrid::error::BuildError
impl Display for CacheError
impl Display for regex_automata::meta::error::BuildError
impl Display for regex_automata::nfa::thompson::error::BuildError
impl Display for GroupInfoError
impl Display for UnicodeWordBoundaryError
impl Display for regex_automata::util::primitives::PatternIDError
impl Display for SmallIndexError
impl Display for regex_automata::util::primitives::StateIDError
impl Display for regex_automata::util::search::MatchError
impl Display for PatternSetInsertError
impl Display for DeserializeError
impl Display for SerializeError
impl Display for regex_syntax::ast::Error
impl Display for regex_syntax::hir::Error
impl Display for Hir
Print a display representation of this Hir.
The result of this is a valid regular expression pattern string.
This implementation uses constant stack space and heap space proportional
to the size of the Hir
.
impl Display for CaseFoldError
impl Display for UnicodeWordError
impl Display for rustix::backend::io::errno::Errno
impl Display for rustls_pki_types::server_name::AddrParseError
impl Display for InvalidDnsNameError
impl Display for ExitStatusWrapper
impl Display for Path
impl Display for LengthDelimitedCodecError
impl Display for Array
impl Display for ArrayOfTables
impl Display for toml_edit::de::Error
impl Display for DocumentMut
impl Display for TomlError
Displays a TOML parse error
§Example
TOML parse error at line 1, column 10
|
1 | 00:32:00.a999999
| ^
Unexpected a
Expected digit
While parsing a Time
While parsing a Date-Time
impl Display for InlineTable
impl Display for InternalString
impl Display for toml_edit::key::Key
impl Display for Table
impl Display for SetGlobalDefaultError
impl Display for Field
impl Display for FieldSet
impl Display for tracing_core::metadata::Level
impl Display for tracing_core::metadata::LevelFilter
impl Display for tracing_core::metadata::ParseLevelError
impl Display for ParseLevelFilterError
impl Display for UnicodeVersion
impl Display for Utf8CharsError
impl Display for Utf16CharsError
impl Display for ContextError
impl Display for winnow::stream::BStr
impl Display for Bytes
impl Display for Range
impl Display for rustmax::anyhow::Error
impl Display for FailedToDeserializeForm
impl Display for FailedToDeserializeFormBody
impl Display for FailedToDeserializePathParams
impl Display for FailedToDeserializeQueryString
impl Display for InvalidFormContentType
impl Display for InvalidUtf8
impl Display for InvalidUtf8InPathParam
impl Display for JsonDataError
impl Display for JsonSyntaxError
impl Display for rustmax::axum::extract::rejection::LengthLimitError
impl Display for MatchedPathMissing
impl Display for MissingExtension
impl Display for MissingJsonContentType
impl Display for MissingPathParams
impl Display for NestedPathRejection
impl Display for UnknownBodyError
impl Display for rustmax::axum::Error
impl Display for Bindings
impl Display for RustTarget
impl Display for rustmax::bitflags::parser::ParseError
impl Display for Hash
impl Display for HexError
impl Display for rustmax::cc::Error
impl Display for FixedOffset
impl Display for NaiveDate
The Display
output of the naive date d
is the same as
d.format("%Y-%m-%d")
.
The string printed can be readily parsed via the parse
method on str
.
§Example
use chrono::NaiveDate;
assert_eq!(format!("{}", NaiveDate::from_ymd_opt(2015, 9, 5).unwrap()), "2015-09-05");
assert_eq!(format!("{}", NaiveDate::from_ymd_opt(0, 1, 1).unwrap()), "0000-01-01");
assert_eq!(format!("{}", NaiveDate::from_ymd_opt(9999, 12, 31).unwrap()), "9999-12-31");
ISO 8601 requires an explicit sign for years before 1 BCE or after 9999 CE.
assert_eq!(format!("{}", NaiveDate::from_ymd_opt(-1, 1, 1).unwrap()), "-0001-01-01");
assert_eq!(format!("{}", NaiveDate::from_ymd_opt(10000, 12, 31).unwrap()), "+10000-12-31");
impl Display for NaiveDateTime
The Display
output of the naive date and time dt
is the same as
dt.format("%Y-%m-%d %H:%M:%S%.f")
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
§Example
use chrono::NaiveDate;
let dt = NaiveDate::from_ymd_opt(2016, 11, 15).unwrap().and_hms_opt(7, 39, 24).unwrap();
assert_eq!(format!("{}", dt), "2016-11-15 07:39:24");
Leap seconds may also be used.
let dt =
NaiveDate::from_ymd_opt(2015, 6, 30).unwrap().and_hms_milli_opt(23, 59, 59, 1_500).unwrap();
assert_eq!(format!("{}", dt), "2015-06-30 23:59:60.500");
impl Display for NaiveTime
The Display
output of the naive time t
is the same as
t.format("%H:%M:%S%.f")
.
The string printed can be readily parsed via the parse
method on str
.
It should be noted that, for leap seconds not on the minute boundary, it may print a representation not distinguishable from non-leap seconds. This doesn’t matter in practice, since such leap seconds never happened. (By the time of the first leap second on 1972-06-30, every time zone offset around the world has standardized to the 5-minute alignment.)
§Example
use chrono::NaiveTime;
assert_eq!(format!("{}", NaiveTime::from_hms_opt(23, 56, 4).unwrap()), "23:56:04");
assert_eq!(
format!("{}", NaiveTime::from_hms_milli_opt(23, 56, 4, 12).unwrap()),
"23:56:04.012"
);
assert_eq!(
format!("{}", NaiveTime::from_hms_micro_opt(23, 56, 4, 1234).unwrap()),
"23:56:04.001234"
);
assert_eq!(
format!("{}", NaiveTime::from_hms_nano_opt(23, 56, 4, 123456).unwrap()),
"23:56:04.000123456"
);
Leap seconds may also be used.
assert_eq!(
format!("{}", NaiveTime::from_hms_milli_opt(6, 59, 59, 1_500).unwrap()),
"06:59:60.500"
);
impl Display for OutOfRange
impl Display for OutOfRangeError
impl Display for rustmax::chrono::ParseError
impl Display for ParseMonthError
impl Display for ParseWeekdayError
impl Display for TimeDelta
impl Display for Utc
impl Display for Str
impl Display for StyledStr
Color-unaware printing. Never uses coloring.
impl Display for ValueRange
impl Display for Arg
impl Display for Command
impl Display for rustmax::clap::Id
impl Display for PanicInfo<'_>
impl Display for PanicMessage<'_>
impl Display for rustmax::crossbeam::channel::RecvError
impl Display for SelectTimeoutError
impl Display for TrySelectError
impl Display for CxxString
impl Display for Exception
impl Display for rustmax::env_logger::fmt::Timestamp
impl Display for Reset
impl Display for Style
impl Display for rustmax::futures::channel::mpsc::SendError
impl Display for rustmax::futures::channel::mpsc::TryRecvError
impl Display for Canceled
impl Display for EnterError
impl Display for Aborted
impl Display for SpawnError
impl Display for InvalidMethod
impl Display for InvalidStatusCode
impl Display for rustmax::hyper::http::Error
impl Display for Authority
impl Display for InvalidUri
impl Display for InvalidUriParts
impl Display for PathAndQuery
impl Display for Scheme
impl Display for rustmax::hyper::Error
impl Display for Uri
impl Display for rustmax::jiff::civil::Date
impl Display for rustmax::jiff::civil::DateTime
Converts a DateTime
into an ISO 8601 compliant string.
Options currently supported:
std::fmt::Formatter::precision
can be set to control the precision of the fractional second component.
§Example
use jiff::civil::date;
let dt = date(2024, 6, 15).at(7, 0, 0, 123_000_000);
assert_eq!(format!("{dt:.6}"), "2024-06-15T07:00:00.123000");
// Precision values greater than 9 are clamped to 9.
assert_eq!(format!("{dt:.300}"), "2024-06-15T07:00:00.123000000");
// A precision of 0 implies the entire fractional
// component is always truncated.
assert_eq!(format!("{dt:.0}"), "2024-06-15T07:00:00");
impl Display for rustmax::jiff::civil::Time
Converts a Time
into an ISO 8601 compliant string.
Options currently supported:
std::fmt::Formatter::precision
can be set to control the precision of the fractional second component.
§Example
use jiff::civil::time;
let t = time(7, 0, 0, 123_000_000);
assert_eq!(format!("{t:.6}"), "07:00:00.123000");
// Precision values greater than 9 are clamped to 9.
assert_eq!(format!("{t:.300}"), "07:00:00.123000000");
// A precision of 0 implies the entire fractional
// component is always truncated.
assert_eq!(format!("{t:.0}"), "07:00:00");
impl Display for rustmax::jiff::Error
impl Display for SignedDuration
impl Display for Span
impl Display for rustmax::jiff::Timestamp
Converts a Timestamp
datetime into a RFC 3339 compliant string.
Since a Timestamp
never has an offset associated with it and is always
in UTC, the string emitted by this trait implementation uses Z
for “Zulu”
time. The significance of Zulu time is prescribed by RFC 9557 and means
that “the time in UTC is known, but the offset to local time is unknown.”
If you need to emit an RFC 3339 compliant string with a specific offset,
then use Timestamp::display_with_offset
.
§Forrmatting options supported
std::fmt::Formatter::precision
can be set to control the precision of the fractional second component.
§Example
use jiff::Timestamp;
let ts = Timestamp::new(1_123_456_789, 123_000_000)?;
assert_eq!(
format!("{ts:.6}"),
"2005-08-07T23:19:49.123000Z",
);
// Precision values greater than 9 are clamped to 9.
assert_eq!(
format!("{ts:.300}"),
"2005-08-07T23:19:49.123000000Z",
);
// A precision of 0 implies the entire fractional
// component is always truncated.
assert_eq!(
format!("{ts:.0}"),
"2005-08-07T23:19:49Z",
);
impl Display for TimestampDisplayWithOffset
impl Display for Zoned
Converts a Zoned
datetime into a RFC 9557 compliant string.
Options currently supported:
std::fmt::Formatter::precision
can be set to control the precision of the fractional second component.
§Example
use jiff::civil::date;
let zdt = date(2024, 6, 15).at(7, 0, 0, 123_000_000).in_tz("US/Eastern")?;
assert_eq!(
format!("{zdt:.6}"),
"2024-06-15T07:00:00.123000-04:00[US/Eastern]",
);
// Precision values greater than 9 are clamped to 9.
assert_eq!(
format!("{zdt:.300}"),
"2024-06-15T07:00:00.123000000-04:00[US/Eastern]",
);
// A precision of 0 implies the entire fractional
// component is always truncated.
assert_eq!(
format!("{zdt:.0}"),
"2024-06-15T07:00:00-04:00[US/Eastern]",
);
impl Display for rustmax::jiff::tz::Offset
impl Display for rustmax::log::ParseLevelError
impl Display for SetLoggerError
impl Display for rustmax::mime::FromStrError
impl Display for Mime
impl Display for BigInt
impl Display for BigUint
impl Display for ParseBigIntError
impl Display for rustmax::proc_macro2::Group
Prints the group as a string that should be losslessly convertible back
into the same group (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters.
impl Display for rustmax::proc_macro2::LexError
impl Display for rustmax::proc_macro2::Literal
impl Display for rustmax::proc_macro2::Punct
Prints the punctuation character as a string that should be losslessly convertible back into the same character.
impl Display for rustmax::proc_macro2::TokenStream
Prints the token stream as a string that is supposed to be losslessly
convertible back into the same token stream (modulo spans), except for
possibly TokenTree::Group
s with Delimiter::None
delimiters and negative
numeric literals.
impl Display for ExpandError
impl Display for rustmax::proc_macro::Group
Prints the group as a string that should be losslessly convertible back
into the same group (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters.
impl Display for rustmax::proc_macro::Ident
Prints the identifier as a string that should be losslessly convertible back into the same identifier.
impl Display for rustmax::proc_macro::LexError
impl Display for rustmax::proc_macro::Literal
Prints the literal as a string that should be losslessly convertible back into the same literal (except for possible rounding for floating point literals).
impl Display for rustmax::proc_macro::Punct
Prints the punctuation character as a string that should be losslessly convertible back into the same character.
impl Display for rustmax::proc_macro::TokenStream
Prints the token stream as a string that is supposed to be losslessly convertible back
into the same token stream (modulo spans), except for possibly TokenTree::Group
s
with Delimiter::None
delimiters and negative numeric literals.
Note: the exact form of the output is subject to change, e.g. there might
be changes in the whitespace used between tokens. Therefore, you should
not do any kind of simple substring matching on the output string (as
produced by to_string
) to implement a proc macro, because that matching
might stop working if such changes happen. Instead, you should work at the
TokenTree
level, e.g. matching against TokenTree::Ident
,
TokenTree::Punct
, or TokenTree::Literal
.
impl Display for PersistedSeed
impl Display for rustmax::proptest::test_runner::Reason
impl Display for TestRunner
impl Display for Empty
impl Display for OsError
impl Display for ThreadPoolBuildError
impl Display for rustmax::regex::bytes::Regex
impl Display for rustmax::regex::Regex
impl Display for HeaderName
impl Display for InvalidHeaderName
impl Display for InvalidHeaderValue
impl Display for MaxSizeReached
impl Display for ToStrError
impl Display for rustmax::reqwest::Error
impl Display for Method
impl Display for StatusCode
Formats the status code, including the canonical reason.
§Example
assert_eq!(format!("{}", StatusCode::OK), "200 OK");
impl Display for BuildMetadata
impl Display for Comparator
impl Display for rustmax::semver::Error
impl Display for Prerelease
impl Display for rustmax::semver::Version
impl Display for VersionReq
impl Display for rustmax::serde::de::value::Error
impl Display for rustmax::serde_json::Error
impl Display for RawValue
impl Display for rustmax::sha2::digest::block_buffer::Error
impl Display for InvalidLength
impl Display for InvalidBufferSize
impl Display for InvalidOutputSize
impl Display for AllocError
impl Display for LayoutError
impl Display for TryFromSliceError
impl Display for rustmax::std::ascii::EscapeDefault
impl Display for Backtrace
impl Display for BorrowError
impl Display for BorrowMutError
impl Display for CharTryFromError
impl Display for DecodeUtf16Error
impl Display for rustmax::std::char::EscapeDebug
impl Display for rustmax::std::char::EscapeDefault
impl Display for rustmax::std::char::EscapeUnicode
impl Display for ParseCharError
impl Display for ToLowercase
impl Display for ToUppercase
impl Display for TryFromCharError
impl Display for UnorderedKeyError
impl Display for rustmax::std::collections::TryReserveError
impl Display for JoinPathsError
impl Display for rustmax::std::ffi::os_str::Display<'_>
impl Display for FromBytesUntilNulError
impl Display for FromBytesWithNulError
impl Display for FromVecWithNulError
impl Display for IntoStringError
impl Display for NulError
impl Display for Arguments<'_>
impl Display for rustmax::std::fmt::Error
impl Display for rustmax::std::io::Error
impl Display for WriterPanicked
impl Display for rustmax::std::net::AddrParseError
impl Display for Ipv4Addr
impl Display for Ipv6Addr
Writes an Ipv6Addr, conforming to the canonical style described by RFC 5952.
impl Display for SocketAddrV4
impl Display for SocketAddrV6
impl Display for rustmax::std::num::ParseFloatError
impl Display for ParseIntError
impl Display for TryFromIntError
impl Display for Location<'_>
impl Display for PanicHookInfo<'_>
impl Display for rustmax::std::path::Display<'_>
impl Display for StripPrefixError
impl Display for ExitStatus
impl Display for ExitStatusError
impl Display for ParseBoolError
impl Display for rustmax::std::str::Utf8Error
impl Display for rustmax::std::string::FromUtf8Error
impl Display for FromUtf16Error
impl Display for String
impl Display for rustmax::std::sync::mpsc::RecvError
impl Display for AccessError
impl Display for SystemTimeError
impl Display for TryFromFloatSecsError
impl Display for rustmax::syn::Error
impl Display for rustmax::syn::Ident
Prints the identifier as a string that should be losslessly convertible back into the same identifier.
impl Display for Lifetime
impl Display for LitFloat
impl Display for LitInt
impl Display for PathPersistError
impl Display for rustmax::tera::Error
impl Display for Number
impl Display for ColorChoiceParseError
impl Display for ParseColorError
impl Display for rustmax::tokio::net::tcp::ReuniteError
impl Display for rustmax::tokio::net::unix::ReuniteError
impl Display for TryCurrentError
impl Display for rustmax::tokio::sync::oneshot::error::RecvError
impl Display for AcquireError
impl Display for rustmax::tokio::sync::TryLockError
impl Display for rustmax::tokio::sync::watch::error::RecvError
impl Display for rustmax::tokio::task::Id
impl Display for JoinError
impl Display for rustmax::tokio::time::error::Elapsed
impl Display for rustmax::tokio::time::error::Error
impl Display for rustmax::toml::de::Error
impl Display for Map<String, Value>
impl Display for rustmax::toml::ser::Error
impl Display for rustmax::toml::value::Date
impl Display for Datetime
impl Display for DatetimeParseError
impl Display for rustmax::toml::value::Time
impl Display for Discover
impl Display for Closed
impl Display for ServiceError
impl Display for Overloaded
impl Display for InvalidBackoff
impl Display for rustmax::tower::timeout::error::Elapsed
impl Display for None
impl Display for Url
Display the serialization of this URL.
impl Display for rustmax::walkdir::Error
impl Display for Cmd<'_>
impl Display for rustmax::xshell::Error
impl Display for rustmax::derive_more::FromStrError
impl Display for UnitError
impl Display for WrongVariantError
impl Display for dyn Value
impl Display for dyn Expected + '_
impl<'a> Display for BytesOrWideString<'a>
impl<'a> Display for Unexpected<'a>
impl<'a> Display for EscapeBytes<'a>
impl<'a> Display for PercentEncode<'a>
impl<'a> Display for Demangle<'a>
impl<'a> Display for ValueSet<'a>
impl<'a> Display for SymbolName<'a>
impl<'a> Display for rustmax::mime::Name<'a>
impl<'a> Display for EscapeAscii<'a>
impl<'a> Display for rustmax::std::str::EscapeDebug<'a>
impl<'a> Display for rustmax::std::str::EscapeDefault<'a>
impl<'a> Display for rustmax::std::str::EscapeUnicode<'a>
impl<'a> Display for ParseBuffer<'a>
impl<'a, 'e, E> Display for Base64Display<'a, 'e, E>where
E: Engine,
impl<'a, I> Display for itertools::format::Format<'a, I>
impl<'a, I> Display for rustmax::itertools::Format<'a, I>
impl<'a, I, B> Display for DelayedFormat<I>
impl<'a, I, F> Display for itertools::format::FormatWith<'a, I, F>
impl<'a, K, V> Display for rustmax::std::collections::hash_map::OccupiedError<'a, K, V>
impl<'a, K, V, A> Display for rustmax::std::collections::btree_map::OccupiedError<'a, K, V, A>
impl<'a, R, G, T> Display for MappedReentrantMutexGuard<'a, R, G, T>
impl<'a, R, G, T> Display for ReentrantMutexGuard<'a, R, G, T>
impl<'a, R, T> Display for lock_api::mutex::MappedMutexGuard<'a, R, T>
impl<'a, R, T> Display for lock_api::mutex::MutexGuard<'a, R, T>
impl<'a, R, T> Display for lock_api::rwlock::MappedRwLockReadGuard<'a, R, T>
impl<'a, R, T> Display for lock_api::rwlock::MappedRwLockWriteGuard<'a, R, T>
impl<'a, R, T> Display for lock_api::rwlock::RwLockReadGuard<'a, R, T>
impl<'a, R, T> Display for RwLockUpgradableReadGuard<'a, R, T>
impl<'a, R, T> Display for lock_api::rwlock::RwLockWriteGuard<'a, R, T>
impl<'a, T> Display for rustmax::tokio::sync::MappedMutexGuard<'a, T>
impl<'a, T> Display for RwLockMappedWriteGuard<'a, T>
impl<'a, T> Display for rustmax::tokio::sync::RwLockReadGuard<'a, T>
impl<'a, T> Display for rustmax::tokio::sync::RwLockWriteGuard<'a, T>
impl<'d> Display for TimeZoneName<'d>
impl<'f> Display for rustmax::jiff::fmt::strtime::Display<'f>
impl<'i, R> Display for Pair<'i, R>where
R: RuleType,
impl<'i, R> Display for Pairs<'i, R>where
R: RuleType,
impl<'k> Display for KeyMut<'k>
impl<'n> Display for Pieces<'n>
impl<'s> Display for StrippedStr<'s>
impl<A, S, V> Display for ConvertError<A, S, V>
Produces a human-readable error message.
The message differs between debug and release builds. When
debug_assertions
are enabled, this message is verbose and includes
potentially sensitive information.
impl<B> Display for Cow<'_, B>
impl<B> Display for BitVec<B>where
B: BitBlock,
impl<E> Display for nom::internal::Err<E>where
E: Debug,
impl<E> Display for ErrMode<E>where
E: Debug,
impl<E> Display for rustmax::nom::Err<E>where
E: Debug,
impl<E> Display for serde_path_to_error::Error<E>where
E: Display,
impl<E> Display for Report<E>where
E: Error,
impl<Enum> Display for TryFromPrimitiveError<Enum>where
Enum: TryFromPrimitive,
impl<F> Display for rustmax::clap::error::Error<F>where
F: ErrorFormatter,
impl<F> Display for FromFn<F>
impl<F> Display for PersistError<F>
impl<I> Display for itertools::exactly_one_err::ExactlyOneError<I>where
I: Iterator,
impl<I> Display for nom::error::Error<I>where
I: Display,
The Display implementation allows the std::error::Error implementation
impl<I> Display for VerboseError<I>where
I: Display,
impl<I> Display for InputError<I>
The Display implementation allows the std::error::Error
implementation
impl<I> Display for TreeErrorBase<I>
impl<I> Display for Located<I>where
I: Display,
impl<I> Display for Partial<I>where
I: Display,
impl<I> Display for rustmax::itertools::ExactlyOneError<I>where
I: Iterator,
impl<I> Display for rustmax::nom::error::Error<I>where
I: Display,
The Display implementation allows the std::error::Error implementation
impl<I, C> Display for TreeError<I, C>
impl<I, C> Display for TreeErrorContext<I, C>
impl<I, E> Display for winnow::error::ParseError<I, E>
impl<I, F> Display for rustmax::itertools::FormatWith<'_, I, F>
impl<I, S> Display for Stateful<I, S>where
I: Display,
impl<K> Display for Failed<K>
impl<K, V> Display for TryIntoHeaderError<K, V>
impl<K, V, S, A> Display for hashbrown::map::OccupiedError<'_, K, V, S, A>
impl<L, R> Display for Either<L, R>
impl<O> Display for zerocopy::byteorder::F32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::F32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::F64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::F64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I16<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I16<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I128<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::I128<O>where
O: ByteOrder,
impl<O> Display for Isize<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U16<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U16<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U32<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U64<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U128<O>where
O: ByteOrder,
impl<O> Display for zerocopy::byteorder::U128<O>where
O: ByteOrder,
impl<O> Display for Usize<O>where
O: ByteOrder,
impl<Ptr> Display for Pin<Ptr>where
Ptr: Display,
impl<R> Display for ErrorVariant<R>where
R: RuleType,
impl<R> Display for pest::error::Error<R>where
R: RuleType,
impl<S> Display for native_tls::HandshakeError<S>
impl<S> Display for openssl::ssl::error::HandshakeError<S>where
S: Debug,
impl<S> Display for Host<S>
impl<Src, Dst> Display for AlignmentError<Src, Dst>
Produces a human-readable error message.
The message differs between debug and release builds. When
debug_assertions
are enabled, this message is verbose and includes
potentially sensitive information.
impl<Src, Dst> Display for SizeError<Src, Dst>
Produces a human-readable error message.
The message differs between debug and release builds. When
debug_assertions
are enabled, this message is verbose and includes
potentially sensitive information.
impl<Src, Dst> Display for ValidityError<Src, Dst>
Produces a human-readable error message.
The message differs between debug and release builds. When
debug_assertions
are enabled, this message is verbose and includes
potentially sensitive information.