pub struct Pooled<T: Default + Reset> { /* private fields */ }
Expand description
Implementations§
Source§impl<T: Default + Reset> Pooled<T>
impl<T: Default + Reset> Pooled<T>
Sourcepub fn detach(this: Self) -> T
pub fn detach(this: Self) -> T
Detach this object from the pool.
It will not be returned to the pool once dropped.
let pool: Pool<String> = Pool::new(69);
let foo: Pooled<String> = pool.take();
assert_eq!(pool.in_use(), 1);
let foo: String = Pooled::detach(foo);
assert_eq!(pool.in_use(), 0);
Sourcepub fn get_pool(this: &Self) -> Option<Pool<T>>
pub fn get_pool(this: &Self) -> Option<Pool<T>>
Get the pool associated with this object.
Objects can outlive the pool they came from, so this returns an Option
.
let pool = Pool::<String>::new(69);
let foo = pool.take();
assert!(Pooled::get_pool(&foo).is_some());
drop(pool);
assert!(Pooled::get_pool(&foo).is_none());
Trait Implementations§
Source§impl<T: Default + Reset> BorrowMut<T> for Pooled<T>
impl<T: Default + Reset> BorrowMut<T> for Pooled<T>
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Ord for Pooled<T>
impl<T> Ord for Pooled<T>
Source§impl<T: Default + Reset + PartialOrd<T>> PartialOrd<T> for Pooled<T>
impl<T: Default + Reset + PartialOrd<T>> PartialOrd<T> for Pooled<T>
Source§impl<T> PartialOrd for Pooled<T>
impl<T> PartialOrd for Pooled<T>
impl<T> Eq for Pooled<T>
Auto Trait Implementations§
impl<T> Freeze for Pooled<T>where
T: Freeze,
impl<T> RefUnwindSafe for Pooled<T>where
T: RefUnwindSafe,
impl<T> Send for Pooled<T>where
T: Send,
impl<T> Sync for Pooled<T>
impl<T> Unpin for Pooled<T>where
T: Unpin,
impl<T> UnwindSafe for Pooled<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