Skip to main content

FormatArg

Enum FormatArg 

Source
pub enum FormatArg<'a> {
    Ref(&'a dyn FormatValue),
    Str(&'a str),
}
Expand description

A format argument - either a trait object reference or a &str slice.

Two variants handle the str unsized coercion gap: &T where T: Sized can coerce to &dyn FormatValue directly, but &str cannot since str is unsized. The Str variant stores the &str directly so that callers can pass string literals without extra & indirection.

Variants§

§

Ref(&'a dyn FormatValue)

A reference to any sized FormatValue.

§

Str(&'a str)

A string slice (avoids the unsized coercion issue).

Trait Implementations§

Source§

impl<'a, T: FormatValue> From<&'a T> for FormatArg<'a>

Source§

fn from(value: &'a T) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<&'a str> for FormatArg<'a>

Source§

fn from(value: &'a str) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for FormatArg<'a>

§

impl<'a> !Send for FormatArg<'a>

§

impl<'a> !Sync for FormatArg<'a>

§

impl<'a> !UnwindSafe for FormatArg<'a>

§

impl<'a> Freeze for FormatArg<'a>

§

impl<'a> Unpin for FormatArg<'a>

§

impl<'a> UnsafeUnpin for FormatArg<'a>

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