pub struct CompactDisplay<'a, T: ?Sized + DisplayCompact> { /* private fields */ }Expand description
A wrapper that implements Display for compact formatting.
This type is returned by DisplayCompact::display and bridges the gap
between the DisplayCompact trait (which requires options) and Rust’s
standard Display trait (which does not).
§Examples
use logosky::utils::sdl_display::DisplayCompact;
struct Data { value: i32 }
impl DisplayCompact for Data {
type Options = ();
fn fmt(&self, f: &mut core::fmt::Formatter<'_>, _: &()) -> core::fmt::Result {
write!(f, "Data({})", self.value)
}
}
let data = Data { value: 42 };
let display_wrapper = data.display(&());
// Now you can use it with format! and println!
assert_eq!(format!("{}", display_wrapper), "Data(42)");Trait Implementations§
Source§impl<T> Display for CompactDisplay<'_, T>where
T: DisplayCompact + ?Sized,
impl<T> Display for CompactDisplay<'_, T>where
T: DisplayCompact + ?Sized,
Source§impl<T> DisplaySDL for CompactDisplay<'_, T>where
T: DisplayCompact + ?Sized,
impl<T> DisplaySDL for CompactDisplay<'_, T>where
T: DisplayCompact + ?Sized,
Auto Trait Implementations§
impl<'a, T> Freeze for CompactDisplay<'a, T>where
T: ?Sized,
impl<'a, T> RefUnwindSafe for CompactDisplay<'a, T>
impl<'a, T> Send for CompactDisplay<'a, T>
impl<'a, T> Sync for CompactDisplay<'a, T>
impl<'a, T> Unpin for CompactDisplay<'a, T>where
T: ?Sized,
impl<'a, T> UnwindSafe for CompactDisplay<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> IntoAmong for T
impl<T> IntoAmong for T
Source§fn into_among_with<F>(self, into_left: F) -> Among<Self, Self, Self>
fn into_among_with<F>(self, into_left: F) -> Among<Self, Self, Self>
Converts
self into a Left variant of Among<Self, Self>
if into_left(&self) returns Some(true). Read moreSource§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more