Struct Metadata
struct Metadata<'a, T> { ... }
where
T: SmartDisplay + ?Sized
Information used to format a value. This is returned by SmartDisplay::metadata.
This type is generic over any user-provided type. This allows the author to store any
information that is needed. For example, a type's implementation of SmartDisplay may need
to calculate something before knowing its width. This calculation can be performed, with the
result being stored in the custom metadata type.
Note that Metadata always contains the width of the type. Authors do not need to store this
information in their custom metadata type.
Generally speaking, a type should be able to be formatted using only its metadata, fields, and the formatter. Any other information should be stored in the metadata type.
Implementations
impl Metadata<'_, Infallible>
fn unpadded_width_of<T>(value: T, f: FormatterOptions) -> usize where T: SmartDisplayObtain the width of the value before padding, given the formatter options.
fn padded_width_of<T>(value: T, f: FormatterOptions) -> usize where T: SmartDisplayObtain the width of the value after padding, given the formatter options.
impl<'a, T> Metadata<'a, T>
const fn new(unpadded_width: usize, _value: &T, metadata: <T as >::Metadata) -> SelfCreates a new
Metadatawith the given width and metadata. While the width should be exact, this is not a requirement for soundness.fn reuse<'b, U>(self: Self) -> Metadata<'b, U> where U: SmartDisplay<Metadata = <T as >::Metadata> + ?Sized, 'a: 'bReuse the metadata for another type. This is useful when implementing
SmartDisplayfor a type that wraps another type. Both type's metadata type must be the same.const fn unpadded_width(self: &Self) -> usizeObtain the width of the value before padding.
fn padded_width(self: &Self, f: FormatterOptions) -> usizeObtain the width of the value after padding.
impl<'a, T> Freeze for Metadata<'a, T>
impl<'a, T> RefUnwindSafe for Metadata<'a, T>
impl<'a, T> Send for Metadata<'a, T>
impl<'a, T> Sync for Metadata<'a, T>
impl<'a, T> Unpin for Metadata<'a, T>
impl<'a, T> UnsafeUnpin for Metadata<'a, T>
impl<'a, T> UnwindSafe for Metadata<'a, T>
impl<P, T> Receiver for Metadata<'a, T>
impl<T> Any for Metadata<'a, T>
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Metadata<'a, T>
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Metadata<'a, T>
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> Clone for Metadata<'_, T>
fn clone(self: &Self) -> Self
impl<T> CloneToUninit for Metadata<'a, T>
unsafe fn clone_to_uninit(self: &Self, dest: *mut u8)
impl<T> Copy for Metadata<'_, T>
impl<T> Debug for Metadata<'_, T>
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl<T> Deref for Metadata<'_, T>
fn deref(self: &Self) -> &<T as >::Metadata
impl<T> From for Metadata<'a, T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Metadata<'a, T>
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Metadata<'a, T>
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Metadata<'a, T>
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>