CompactDisplay

Struct CompactDisplay 

Source
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,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> DisplaySDL for CompactDisplay<'_, T>
where T: DisplayCompact + ?Sized,

Source§

type Options = <T as DisplayCompact>::Options

The options type that controls formatting behavior. Read more
Source§

fn fmt(&self, f: &mut Formatter<'_>, options: &Self::Options) -> Result

Formats the value with the given options. Read more
Source§

fn display<'a>(&'a self, options: &'a Self::Options) -> impl Display + 'a

Returns a wrapper that implements Display with the given options. Read more

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>
where T: Sync + ?Sized, <T as DisplayCompact>::Options: Sync,

§

impl<'a, T> Sync for CompactDisplay<'a, T>
where T: Sync + ?Sized, <T as DisplayCompact>::Options: Sync,

§

impl<'a, T> Unpin for CompactDisplay<'a, T>
where T: ?Sized,

§

impl<'a, T> UnwindSafe for CompactDisplay<'a, T>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoAmong for T

Source§

fn into_among(self, into_left: Option<bool>) -> Among<Self, Self, Self>

Converts self into a Left variant of Among<Self, Self> if into_left is Some(true). Read more
Source§

fn into_among_with<F>(self, into_left: F) -> Among<Self, Self, Self>
where F: FnOnce(&Self) -> Option<bool>,

Converts self into a Left variant of Among<Self, Self> if into_left(&self) returns Some(true). Read more
Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.