Struct Display
pub struct Display<'f> { /* private fields */ }
A "lazy" implementation of std::fmt::Display for strftime.
Values of this type are created by the strftime methods on the various
datetime types in this crate. For example, [Zoned::strftime].
A Display captures the information needed from the datetime and waits to
do the actual formatting when this type's std::fmt::Display trait
implementation is actually used.
Errors and panics
This trait implementation configures formatting to use
lenient mode. This avoids panics occuring when using
APIs like Timestamp::strftime with unsupported or invalid formatting
directives. Without lenient mode, whenever formatting would fail, this
would surface as a panic when converting this display implementation to
a string.
Example
This example shows how to format a zoned datetime using
[Zoned::strftime]:
use date;
let zdt = date.at.in_tz?;
let string = zdt.strftime.to_string;
assert_eq!;
# Ok::
Or use it directly when writing to something:
use ;
let zdt = date.at.in_tz?;
let string = format!;
assert_eq!;
# Ok::
Example: errors are silently ignored
If the formatting string is malformed in some way, then it is silently ignored. For example, when using an invalid formatting directive:
use Zoned;
let zdt = UNIX_EPOCH;
let string = zdt.strftime.to_string;
assert_eq!;
If one wants to surface errors from a formatting string, use a lower level API:
use Zoned;
let zdt = UNIX_EPOCH;
assert_eq!;
Trait Implementations
impl<'f> Debug for Display<'f>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'f> Display for Display<'f>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
Auto Trait Implementations
impl<'f> Freeze for Display<'f>
impl<'f> RefUnwindSafe for Display<'f>
impl<'f> Send for Display<'f>
impl<'f> Sync for Display<'f>
impl<'f> Unpin for Display<'f>
impl<'f> UnsafeUnpin for Display<'f>
impl<'f> UnwindSafe for Display<'f>
Blanket Implementations
impl<T> Any for Display<'f>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Display<'f>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Display<'f>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for Display<'f>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToString for Display<'f>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for Display<'f>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Display<'f>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Display<'f>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>