Struct PoolGuard

struct PoolGuard<'a, T: Send, F: Fn() -> T>(_)

A guard that is returned when a caller requests a value from the pool.

The purpose of the guard is to use RAII to automatically put the value back in the pool once it's dropped.

Implementations

impl<'a, T: Send, F: Fn() -> T> PoolGuard<'a, T, F>

fn put(this: PoolGuard<'_, T, F>)

Consumes this guard and puts it back into the pool.

This circumvents the guard's Drop implementation. This can be useful in circumstances where the automatic Drop results in poorer codegen, such as calling non-inlined functions.

impl<'a, T, F> Freeze for PoolGuard<'a, T, F>

impl<'a, T, F> RefUnwindSafe for PoolGuard<'a, T, F>

impl<'a, T, F> Send for PoolGuard<'a, T, F>

impl<'a, T, F> Sync for PoolGuard<'a, T, F>

impl<'a, T, F> Unpin for PoolGuard<'a, T, F>

impl<'a, T, F> UnsafeUnpin for PoolGuard<'a, T, F>

impl<'a, T, F> UnwindSafe for PoolGuard<'a, T, F>

impl<'a, T: Send + core::fmt::Debug, F: Fn() -> T> Debug for PoolGuard<'a, T, F>

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

impl<'a, T: Send, F: Fn() -> T> Deref for PoolGuard<'a, T, F>

fn deref(self: &Self) -> &T

impl<'a, T: Send, F: Fn() -> T> DerefMut for PoolGuard<'a, T, F>

fn deref_mut(self: &mut Self) -> &mut T

impl<P, T> Receiver for PoolGuard<'a, T, F>

impl<T> Any for PoolGuard<'a, T, F>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for PoolGuard<'a, T, F>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for PoolGuard<'a, T, F>

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

impl<T> From for PoolGuard<'a, T, F>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for PoolGuard<'a, T, F>

fn into(self: 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 for PoolGuard<'a, T, F>

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

impl<T, U> TryInto for PoolGuard<'a, T, F>

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