pub struct BufferGuard<M: RawMutex + 'static, T> { /* private fields */ }Expand description
Exclusive handle to one pooled T. Releasing the slot on Drop.
Derefs to T via Deref / DerefMut. Use BufferGuard::map to borrow a
subfield or slice while keeping the same pool slot.
Implementations§
Source§impl<M: RawMutex + 'static, T> BufferGuard<M, T>
impl<M: RawMutex + 'static, T> BufferGuard<M, T>
Sourcepub fn map<U: ?Sized>(
orig: Self,
fun: impl FnOnce(&mut T) -> &mut U,
) -> MappedBufferGuard<M, U>
pub fn map<U: ?Sized>( orig: Self, fun: impl FnOnce(&mut T) -> &mut U, ) -> MappedBufferGuard<M, U>
Narrows the guard to a &mut U derived from the buffer (for example a slice into
a larger [u8]). The original guard is consumed without running its Drop; the
returned MappedBufferGuard still returns the pool slot when dropped.
This is an associated function, not a method: the guard is passed as orig,
not self. You call it as BufferGuard::map(guard, f). If the first parameter
were self, guard.map(...) would always resolve to this routine and shadow
a map method on T; with orig: Self, guard.map(...) can still go through
Deref / DerefMut to T::map when you want the inner value’s API.