pub struct Pool<const S: usize, T: 'static> { /* private fields */ }
Expand description
A sharded pool of elements.
Implementations§
Source§impl<const S: usize, T: Default + Reuse> Pool<S, T>
impl<const S: usize, T: Default + Reuse> Pool<S, T>
Sourcepub fn get(&'static self) -> Pooled<T>
pub fn get(&'static self) -> Pooled<T>
Get a value from the pool, or create a new default value if the assigned shard is currently empty.
Sourcepub fn get_empty(&'static self) -> Pooled<T>
pub fn get_empty(&'static self) -> Pooled<T>
Create a new default value assigned for a pool, if it is ends up being expanded and eligible for reuse it will return to the pool, otherwise it will end up being dropped.
Sourcepub fn get_with(&'static self, f: impl Fn(&mut T)) -> Pooled<T>
pub fn get_with(&'static self, f: impl Fn(&mut T)) -> Pooled<T>
Get a value from the pool and apply the provided transformation on it before returning.
pub fn from_owned(&'static self, inner: T) -> Pooled<T>
Trait Implementations§
Auto Trait Implementations§
impl<const S: usize, T> !Freeze for Pool<S, T>
impl<const S: usize, T> RefUnwindSafe for Pool<S, T>
impl<const S: usize, T> Send for Pool<S, T>where
T: Send,
impl<const S: usize, T> Sync for Pool<S, T>where
T: Send,
impl<const S: usize, T> Unpin for Pool<S, T>where
T: Unpin,
impl<const S: usize, T> UnwindSafe for Pool<S, T>
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