Struct DebugOnce

pub(in ::fmt::builders) struct DebugOnce<F>(pub(in ::fmt::builders) Cell<Option<F>>);

Wraps an FnOnce formatting closure in a type that implements fmt::Debug by calling the closure, allowing the *_with builder methods to forward to their &dyn fmt::Debug counterparts.

By doing this, the builder logic is monomorphized only once and not for every closure type (see #149745).

Formatting a DebugOnce consumes the closure, so attempting to format it more than once panics. This never happens because the debug builders format each value exactly once.

Fields

0: Cell<Option<F>>

Trait Implementations

impl<F> Debug for DebugOnce<F> where F: FnOnce(&mut Formatter<'_>) -> Result,

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

Auto Trait Implementations

impl<F> !Freeze for DebugOnce<F>

impl<F> !RefUnwindSafe for DebugOnce<F>

impl<F> !Sync for DebugOnce<F>

impl<F> Send for DebugOnce<F> where Cell<Option<F>>: Send,

impl<F> Unpin for DebugOnce<F> where Cell<Option<F>>: Unpin,

impl<F> UnsafeUnpin for DebugOnce<F> where Cell<Option<F>>: UnsafeUnpin,

impl<F> UnwindSafe for DebugOnce<F> where Cell<Option<F>>: UnwindSafe,

Blanket Implementations

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

fn type_id(&self) -> TypeId

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

fn borrow(&self) -> &T

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

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

impl<T> From<T> for DebugOnce<F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> SizeHint for DebugOnce<F> where T: ?Sized,

fn lower_bound(&self) -> usize
fn upper_bound(&self) -> Option<usize>

impl<T> SizedTypeProperties for DebugOnce<F>

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

fn into(self) -> U

Calls U::from(self).

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

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

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

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

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