pub struct LeasePool<T>{ /* private fields */ }Expand description
Pool of reusable values with single-cell items that are not cloneable.
Items stay in the pool while checked out; Self::acquire hands back a
LeaseHandle pointing at one and flags it leased. Dropping the handle reclaims the
value and frees the slot, so allocations are reused across acquires instead of allocating anew.
Implementations§
Source§impl<T> LeasePool<T>
impl<T> LeasePool<T>
Sourcepub fn with_capacity(capacity: usize) -> LeasePool<T>
pub fn with_capacity(capacity: usize) -> LeasePool<T>
Pre-reserve room for capacity pooled items (if exceeded, the pool still grows on demand).
Sourcepub fn acquire(&mut self) -> LeaseHandle<T>
pub fn acquire(&mut self) -> LeaseHandle<T>
Take an item, reusing a free pooled item when available.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for LeasePool<T>
impl<T> Freeze for LeasePool<T>
impl<T> Send for LeasePool<T>
impl<T> Sync for LeasePool<T>
impl<T> Unpin for LeasePool<T>
impl<T> UnsafeUnpin for LeasePool<T>
impl<T> UnwindSafe for LeasePool<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more