use crate::base::cell::{
local::Read,
region::{self, Brand},
};
#[repr(transparent)]
pub struct Access<'borrow, B: Brand> {
pub(in crate::base::cell) region: &'borrow mut region::Token<B>,
}
impl<'borrow, B: Brand> Access<'borrow, B> {
pub fn new(region: &'borrow mut region::Token<B>) -> Self {
Self { region }
}
pub fn reborrow(&mut self) -> Access<'_, B> {
Access {
region: self.region,
}
}
pub fn read(&self) -> Read<'_, B> {
Read::new(self.region)
}
pub fn with_region<R>(self, f: impl for<'a> FnOnce(&'a mut region::Token<B>) -> R) -> R {
f(self.region)
}
}