mod derivations;
use std::sync::{
RwLock,
RwLockReadGuard,
RwLockWriteGuard
};
#[derive(Debug)]
pub struct Cage<Type: ?Sized> {
being: RwLock<Type>
}
impl<Type: Sized> Cage<Type> {
pub const fn new(value: Type) -> Cage<Type> {return Self {
being: RwLock::new(value)
}}
pub fn release(self) -> Type {return self.being.into_inner().unwrap()}
}
impl<Type: ?Sized> Cage<Type> {
#[inline]
pub fn read<'valid>(&'valid self) -> RwLockReadGuard<'valid, Type> {return self.being.read().unwrap()}
#[inline]
pub fn write<'valid>(&'valid self) -> RwLockWriteGuard<'valid, Type> {return self.being.write().unwrap()}
}
impl<Type: Copy> Cage<Type> {
#[inline]
pub fn get(&self) -> Type {*self.read()}
}
impl<Type: Clone> Cage<Type> {
#[inline]
pub fn cloned(&self) -> Type {self.read().clone()}
}