qwutils/scoped/mod.rs
1pub mod imp;
2pub mod macros;
3/// a type which inner type T can be accessed scoped
4///
5/// use impl_scoped_mut!(T) if a implementation is missing
6pub trait ScopedMut {
7 type T;
8
9 fn access<R>(&self, f: impl FnOnce(&Self::T)->R) -> R;
10 fn access_mut<R>(&mut self, f: impl FnOnce(&mut Self::T)->R) -> R;
11}
12/// like ScopedMut, but explict with interior mutability
13pub trait Interior {
14 type T;
15
16 fn interior_access<R>(&self, f: impl FnOnce(&Self::T)->R) -> R;
17 fn interior_access_mut<R>(&self, f: impl FnOnce(&mut Self::T)->R) -> R;
18}