use crate::*;
use std::cell::RefCell;
use std::rc::Rc;
pub struct RcPool<T: Sized>(Rc<RefCell<PoolInner<T>>>);
impl<T> RcPool<T> {
#[inline]
#[must_use]
pub fn new() -> Self {
Self(Rc::new(RefCell::new(PoolInner::new())))
}
}
impl<T> Clone for RcPool<T> {
fn clone(&self) -> Self {
Self(self.0.clone())
}
}
impl<T> PoolApi<T> for RcPool<T> {}
impl<T> PoolLock<T> for &RcPool<T> {
#[inline]
fn with_lock<R, F: FnOnce(&mut PoolInner<T>) -> R>(self, f: F) -> R {
f(&mut self.0.borrow_mut())
}
}
impl<T> Default for RcPool<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> AsRef<RcPool<T>> for RcPool<T> {
fn as_ref(&self) -> &Self {
self
}
}