WithContainer

Trait WithContainer 

Source
pub trait WithContainer<Root, Value> {
Show 16 methods // Required methods fn with_arc<F, R>(&self, arc: &Arc<Root>, f: F) -> R where F: FnOnce(&Value) -> R; fn with_box<F, R>(&self, boxed: &Box<Root>, f: F) -> R where F: FnOnce(&Value) -> R; fn with_box_mut<F, R>(&self, boxed: &mut Box<Root>, f: F) -> R where F: FnOnce(&mut Value) -> R; fn with_rc<F, R>(&self, rc: &Rc<Root>, f: F) -> R where F: FnOnce(&Value) -> R; fn with_result<F, R, E>(&self, result: &Result<Root, E>, f: F) -> Option<R> where F: FnOnce(&Value) -> R; fn with_result_mut<F, R, E>( &self, result: &mut Result<Root, E>, f: F, ) -> Option<R> where F: FnOnce(&mut Value) -> R; fn with_option<F, R>(&self, option: &Option<Root>, f: F) -> Option<R> where F: FnOnce(&Value) -> R; fn with_option_mut<F, R>( &self, option: &mut Option<Root>, f: F, ) -> Option<R> where F: FnOnce(&mut Value) -> R; fn with_refcell<F, R>(&self, refcell: &RefCell<Root>, f: F) -> Option<R> where F: FnOnce(&Value) -> R; fn with_refcell_mut<F, R>(&self, refcell: &RefCell<Root>, f: F) -> Option<R> where F: FnOnce(&mut Value) -> R; fn with_mutex<F, R>(&self, mutex: &Mutex<Root>, f: F) -> Option<R> where F: FnOnce(&Value) -> R; fn with_mutex_mut<F, R>(&self, mutex: &mut Mutex<Root>, f: F) -> Option<R> where F: FnOnce(&mut Value) -> R; fn with_rwlock<F, R>(&self, rwlock: &RwLock<Root>, f: F) -> Option<R> where F: FnOnce(&Value) -> R; fn with_rwlock_mut<F, R>( &self, rwlock: &mut RwLock<Root>, f: F, ) -> Option<R> where F: FnOnce(&mut Value) -> R; fn with_arc_rwlock<F, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: F, ) -> Option<R> where F: FnOnce(&Value) -> R; fn with_arc_rwlock_mut<F, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: F, ) -> Option<R> where F: FnOnce(&mut Value) -> R;
}
Expand description

Trait for no-clone callback-based access to container types Provides methods to execute closures with references to values inside containers without requiring cloning of the values

Required Methods§

Source

fn with_arc<F, R>(&self, arc: &Arc<Root>, f: F) -> R
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc

Source

fn with_box<F, R>(&self, boxed: &Box<Root>, f: F) -> R
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Box

Source

fn with_box_mut<F, R>(&self, boxed: &mut Box<Root>, f: F) -> R
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Box

Source

fn with_rc<F, R>(&self, rc: &Rc<Root>, f: F) -> R
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Rc

Source

fn with_result<F, R, E>(&self, result: &Result<Root, E>, f: F) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Result

Source

fn with_result_mut<F, R, E>( &self, result: &mut Result<Root, E>, f: F, ) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Result

Source

fn with_option<F, R>(&self, option: &Option<Root>, f: F) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Option

Source

fn with_option_mut<F, R>(&self, option: &mut Option<Root>, f: F) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an Option

Source

fn with_refcell<F, R>(&self, refcell: &RefCell<Root>, f: F) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a RefCell

Source

fn with_refcell_mut<F, R>(&self, refcell: &RefCell<Root>, f: F) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a RefCell

Source

fn with_mutex<F, R>(&self, mutex: &Mutex<Root>, f: F) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside a Mutex

Source

fn with_mutex_mut<F, R>(&self, mutex: &mut Mutex<Root>, f: F) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside a Mutex

Source

fn with_rwlock<F, R>(&self, rwlock: &RwLock<Root>, f: F) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an RwLock

Source

fn with_rwlock_mut<F, R>(&self, rwlock: &mut RwLock<Root>, f: F) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an RwLock

Source

fn with_arc_rwlock<F, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: F, ) -> Option<R>
where F: FnOnce(&Value) -> R,

Execute a closure with a reference to the value inside an Arc<RwLock>

Source

fn with_arc_rwlock_mut<F, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: F, ) -> Option<R>
where F: FnOnce(&mut Value) -> R,

Execute a closure with a mutable reference to the value inside an Arc<RwLock>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Root, Value, F> WithContainer<Root, Value> for KeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> &'r Value + Clone,

Source§

impl<Root, Value, F> WithContainer<Root, Value> for OptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r Root) -> Option<&'r Value> + Clone,

Source§

impl<Root, Value, F> WithContainer<Root, Value> for WritableKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r mut Root) -> &'r mut Value,

Source§

impl<Root, Value, F> WithContainer<Root, Value> for WritableOptionalKeyPath<Root, Value, F>
where F: for<'r> Fn(&'r mut Root) -> Option<&'r mut Value>,