Trait kvarn_utils::prelude::Display
1.0.0 · source · [−]Expand description
Format trait for an empty format, {}
.
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.
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
Formats the value using the given formatter.
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, }));
Implementations on Foreign Types
1.8.0 · sourceimpl Display for SystemTimeError
impl Display for SystemTimeError
sourceimpl Display for JoinPathsError
impl Display for JoinPathsError
sourceimpl<T> Display for TryLockError<T>
impl<T> Display for TryLockError<T>
1.15.0 · sourceimpl Display for RecvTimeoutError
impl Display for RecvTimeoutError
1.26.0 · sourceimpl Display for AccessError
impl Display for AccessError
sourceimpl<T> Display for PoisonError<T>
impl<T> Display for PoisonError<T>
sourceimpl<T> Display for TrySendError<T>
impl<T> Display for TrySendError<T>
1.20.0 · sourceimpl<'_, T> Display for RwLockReadGuard<'_, T> where
T: Display + ?Sized,
impl<'_, T> Display for RwLockReadGuard<'_, T> where
T: Display + ?Sized,
1.7.0 · sourceimpl Display for StripPrefixError
impl Display for StripPrefixError
1.20.0 · sourceimpl<'_, T> Display for MutexGuard<'_, T> where
T: Display + ?Sized,
impl<'_, T> Display for MutexGuard<'_, T> where
T: Display + ?Sized,
sourceimpl<'a, K, V> Display for OccupiedError<'a, K, V> where
K: Debug,
V: Debug,
impl<'a, K, V> Display for OccupiedError<'a, K, V> where
K: Debug,
V: Debug,
sourceimpl Display for ExitStatusError
impl Display for ExitStatusError
1.20.0 · sourceimpl<'_, T> Display for RwLockWriteGuard<'_, T> where
T: Display + ?Sized,
impl<'_, T> Display for RwLockWriteGuard<'_, T> where
T: Display + ?Sized,
1.34.0 · sourceimpl Display for NonZeroIsize
impl Display for NonZeroIsize
1.16.0 · sourceimpl Display for ToUppercase
impl Display for ToUppercase
1.28.0 · sourceimpl Display for NonZeroU32
impl Display for NonZeroU32
1.34.0 · sourceimpl Display for NonZeroI64
impl Display for NonZeroI64
1.13.0 · sourceimpl Display for BorrowError
impl Display for BorrowError
sourceimpl<T> Display for Saturating<T> where
T: Display,
impl<T> Display for Saturating<T> where
T: Display,
1.20.0 · sourceimpl Display for EscapeDebug
impl Display for EscapeDebug
1.59.0 · sourceimpl Display for TryFromCharError
impl Display for TryFromCharError
1.28.0 · sourceimpl Display for NonZeroU16
impl Display for NonZeroU16
1.34.0 · sourceimpl Display for NonZeroI16
impl Display for NonZeroI16
1.9.0 · sourceimpl Display for DecodeUtf16Error
impl Display for DecodeUtf16Error
1.34.0 · sourceimpl Display for Infallible
impl Display for Infallible
1.16.0 · sourceimpl Display for ToLowercase
impl Display for ToLowercase
1.28.0 · sourceimpl Display for NonZeroU128
impl Display for NonZeroU128
1.36.0 · sourceimpl Display for TryFromSliceError
impl Display for TryFromSliceError
sourceimpl Display for FromBytesUntilNulError
impl Display for FromBytesUntilNulError
1.39.0 · sourceimpl Display for EscapeDefault
impl Display for EscapeDefault
1.34.0 · sourceimpl Display for NonZeroI128
impl Display for NonZeroI128
1.13.0 · sourceimpl Display for BorrowMutError
impl Display for BorrowMutError
1.17.0 · sourceimpl Display for FromBytesWithNulError
impl Display for FromBytesWithNulError
1.16.0 · sourceimpl Display for EscapeDefault
impl Display for EscapeDefault
1.60.0 · sourceimpl<'a> Display for EscapeAscii<'a>
impl<'a> Display for EscapeAscii<'a>
1.28.0 · sourceimpl Display for LayoutError
impl Display for LayoutError
1.34.0 · sourceimpl Display for TryFromIntError
impl Display for TryFromIntError
sourceimpl Display for ParseFloatError
impl Display for ParseFloatError
1.16.0 · sourceimpl Display for EscapeUnicode
impl Display for EscapeUnicode
1.34.0 · sourceimpl Display for NonZeroI32
impl Display for NonZeroI32
1.20.0 · sourceimpl Display for ParseCharError
impl Display for ParseCharError
1.28.0 · sourceimpl Display for NonZeroUsize
impl Display for NonZeroUsize
1.28.0 · sourceimpl Display for NonZeroU64
impl Display for NonZeroU64
sourceimpl Display for FromFloatSecsError
impl Display for FromFloatSecsError
1.34.0 · sourceimpl Display for CharTryFromError
impl Display for CharTryFromError
1.57.0 · sourceimpl Display for TryReserveError
impl Display for TryReserveError
1.7.0 · sourceimpl Display for IntoStringError
impl Display for IntoStringError
sourceimpl Display for FromUtf16Error
impl Display for FromUtf16Error
1.58.0 · sourceimpl Display for FromVecWithNulError
impl Display for FromVecWithNulError
sourceimpl Display for InvalidStatusCode
impl Display for InvalidStatusCode
sourceimpl Display for SetLoggerError
impl Display for SetLoggerError
sourceimpl Display for ParseLevelError
impl Display for ParseLevelError
sourceimpl<'a> Display for PercentEncode<'a>
impl<'a> Display for PercentEncode<'a>
Implementors
impl Display for IpAddr
impl Display for SocketAddr
impl Display for ErrorKind
impl Display for kvarn_utils::prelude::fmt::Error
impl Display for InvalidHeaderName
impl Display for InvalidHeaderValue
impl Display for ToStrError
impl Display for kvarn_utils::prelude::io::Error
impl Display for WriterPanicked
impl Display for AddrParseError
impl Display for Ipv4Addr
impl Display for Ipv6Addr
Write an Ipv6Addr, conforming to the canonical style described by RFC 5952.
impl Display for SocketAddrV4
impl Display for SocketAddrV6
impl Display for ParseBoolError
impl Display for Utf8Error
impl Display for HeaderName
impl Display for Method
impl Display for StatusCode
Formats the status code, including the canonical reason.
Example
assert_eq!(format!("{}", StatusCode::OK), "200 OK");