Struct PoolGuard
pub struct PoolGuard<'a, T: Send, F: Fn() -> T>(/* private field */);
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
Dropimplementation. This can be useful in circumstances where the automaticDropresults in poorer codegen, such as calling non-inlined functions.
Trait Implementations
impl<'a, T: Send + Debug, F: Fn() -> T> Debug for PoolGuard<'a, T, F>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<'a, T: Send, F: Fn() -> T> Deref for PoolGuard<'a, T, F>
type Target = T;fn deref(&self) -> &T
impl<'a, T: Send, F: Fn() -> T> DerefMut for PoolGuard<'a, T, F>
fn deref_mut(&mut self) -> &mut T
Auto Trait Implementations
impl<'a, T, F> Freeze for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: Freeze,
impl<'a, T, F> RefUnwindSafe for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: RefUnwindSafe,
impl<'a, T, F> Send for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: Send,
impl<'a, T, F> Sync for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: Sync,
impl<'a, T, F> Unpin for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: Unpin,
impl<'a, T, F> UnsafeUnpin for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: UnsafeUnpin,
impl<'a, T, F> UnwindSafe for PoolGuard<'a, T, F>
where
PoolGuard<'a, T, F>: UnwindSafe,
Blanket Implementations
impl<P, T> Receiver for PoolGuard<'a, T, F>
where
P: Deref<Target = T> + ?Sized,
T: ?Sized,
type Target = T;
impl<T> Any for PoolGuard<'a, T, F>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for PoolGuard<'a, T, F>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for PoolGuard<'a, T, F>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for PoolGuard<'a, T, F>
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into<U> for PoolGuard<'a, T, F>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for PoolGuard<'a, T, F>
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for PoolGuard<'a, T, F>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>