Struct LocalRecorderGuard

Source
pub struct LocalRecorderGuard<'a> { /* private fields */ }
Expand description

Guard for setting a local recorder.

When using a local recorder, we take a reference to the recorder and only hold it for as long as the duration of the closure. However, we must store this reference in a static variable (thread-local storage) so that it can be accessed by the macros. This guard ensures that the pointer we store to the reference is cleared when the guard is dropped, so that it can’t be used after the closure has finished, even if the closure panics and unwinds the stack.

§Note

The guard has a lifetime parameter 'a that is bounded using a PhantomData type. This upholds the guard’s contravariance, it must live at most as long as the recorder it takes a reference to. The bounded lifetime prevents accidental use-after-free errors when using a guard directly through crate::set_default_local_recorder.

Trait Implementations§

Source§

impl<'a> Drop for LocalRecorderGuard<'a>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for LocalRecorderGuard<'a>

§

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

§

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

§

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

§

impl<'a> Unpin for LocalRecorderGuard<'a>

§

impl<'a> !UnwindSafe for LocalRecorderGuard<'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.