pub struct KeyPath<Root, Value, F>{ /* private fields */ }Implementations§
Source§impl<Root, Value, F> KeyPath<Root, Value, F>
impl<Root, Value, F> KeyPath<Root, Value, F>
pub fn new(getter: F) -> Self
pub fn get<'r>(&self, root: &'r Root) -> &'r Value
pub fn for_box<Target>(
self,
) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> &'r Target + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_arc<Target>(
self,
) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> &'r Target + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_rc<Target>(
self,
) -> KeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> &'r Target + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_arc_root(
self,
) -> OptionalKeyPath<Arc<Root>, Value, impl for<'r> Fn(&'r Arc<Root>) -> Option<&'r Value> + 'static>where
Value: Sized + 'static,
F: 'static,
Root: 'static,
pub fn for_box_root(
self,
) -> OptionalKeyPath<Box<Root>, Value, impl for<'r> Fn(&'r Box<Root>) -> Option<&'r Value> + 'static>where
Value: Sized + 'static,
F: 'static,
Root: 'static,
pub fn for_rc_root(
self,
) -> OptionalKeyPath<Rc<Root>, Value, impl for<'r> Fn(&'r Rc<Root>) -> Option<&'r Value> + 'static>where
Value: Sized + 'static,
F: 'static,
Root: 'static,
Sourcepub fn for_result<E>(
self,
) -> OptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r Result<Root, E>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
E: 'static,
pub fn for_result<E>(
self,
) -> OptionalKeyPath<Result<Root, E>, Value, impl for<'r> Fn(&'r Result<Root, E>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
E: 'static,
Adapt this keypath to work with Result<Root, E> instead of Root This unwraps the Result and applies the keypath to the Ok value
Sourcepub fn to_optional(
self,
) -> OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>where
F: 'static,
pub fn to_optional(
self,
) -> OptionalKeyPath<Root, Value, impl for<'r> Fn(&'r Root) -> Option<&'r Value> + 'static>where
F: 'static,
Convert a KeyPath to OptionalKeyPath for chaining This allows non-optional keypaths to be chained with then()
Sourcepub fn with_option<Callback, R>(
&self,
option: &Option<Root>,
f: Callback,
) -> Option<R>
pub fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Option
Sourcepub fn with_result<Callback, R, E>(
&self,
result: &Result<Root, E>,
f: Callback,
) -> Option<R>
pub fn with_result<Callback, R, E>( &self, result: &Result<Root, E>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside a Result
Sourcepub fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
pub fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
Execute a closure with a reference to the value inside a Box
Sourcepub fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
pub fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
Execute a closure with a reference to the value inside an Arc
Sourcepub fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
pub fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
Execute a closure with a reference to the value inside an Rc
Sourcepub fn with_refcell<Callback, R>(
&self,
refcell: &RefCell<Root>,
f: Callback,
) -> Option<R>
pub fn with_refcell<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside a RefCell
Sourcepub fn with_mutex<Callback, R>(
&self,
mutex: &Mutex<Root>,
f: Callback,
) -> Option<R>
pub fn with_mutex<Callback, R>( &self, mutex: &Mutex<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside a Mutex
Sourcepub fn with_rwlock<Callback, R>(
&self,
rwlock: &RwLock<Root>,
f: Callback,
) -> Option<R>
pub fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an RwLock
Sourcepub fn with_arc_rwlock<Callback, R>(
&self,
arc_rwlock: &Arc<RwLock<Root>>,
f: Callback,
) -> Option<R>
pub fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Arc<RwLock
Sourcepub fn with_arc_mutex<Callback, R>(
&self,
arc_mutex: &Arc<Mutex<Root>>,
f: Callback,
) -> Option<R>
pub fn with_arc_mutex<Callback, R>( &self, arc_mutex: &Arc<Mutex<Root>>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Arc<Mutex
Sourcepub fn for_option(
self,
) -> OptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r Option<Root>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
pub fn for_option(
self,
) -> OptionalKeyPath<Option<Root>, Value, impl for<'r> Fn(&'r Option<Root>) -> Option<&'r Value> + 'static>where
F: 'static,
Root: 'static,
Value: 'static,
Adapt this keypath to work with Option
Sourcepub fn iter<'r, T>(&self, root: &'r Root) -> Option<Iter<'r, T>>
pub fn iter<'r, T>(&self, root: &'r Root) -> Option<Iter<'r, T>>
Get an iterator over a Vec when Value is Vec
Sourcepub fn extract_from_slice<'r>(&self, slice: &'r [Root]) -> Vec<&'r Value>
pub fn extract_from_slice<'r>(&self, slice: &'r [Root]) -> Vec<&'r Value>
Extract values from a slice of owned values Returns a Vec of references to the extracted values
Sourcepub fn extract_from_ref_slice<'r>(&self, slice: &'r [&Root]) -> Vec<&'r Value>
pub fn extract_from_ref_slice<'r>(&self, slice: &'r [&Root]) -> Vec<&'r Value>
Extract values from a slice of references Returns a Vec of references to the extracted values
Sourcepub fn then<SubValue, G>(
self,
next: KeyPath<Value, SubValue, G>,
) -> KeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> &'r SubValue>
pub fn then<SubValue, G>( self, next: KeyPath<Value, SubValue, G>, ) -> KeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> &'r SubValue>
Chain this keypath with another keypath Returns a KeyPath that chains both keypaths
Sourcepub fn then_optional<SubValue, G>(
self,
next: OptionalKeyPath<Value, SubValue, G>,
) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> Option<&'r SubValue>>
pub fn then_optional<SubValue, G>( self, next: OptionalKeyPath<Value, SubValue, G>, ) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> Option<&'r SubValue>>
Chain this keypath with an optional keypath Returns an OptionalKeyPath that chains both keypaths
Source§impl<Root, Value, F> KeyPath<Root, Value, F>
impl<Root, Value, F> KeyPath<Root, Value, F>
Sourcepub fn with_arc_rwlock_direct<Callback, R>(
&self,
arc_rwlock: &Arc<RwLock<Root>>,
f: Callback,
) -> Option<R>
pub fn with_arc_rwlock_direct<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
Execute a closure with a reference to the value inside an Arc<RwLock
Source§impl<Root, Value, F> KeyPath<Root, Value, F>
impl<Root, Value, F> KeyPath<Root, Value, F>
Sourcepub fn to_partial(self) -> PartialKeyPath<Root>
pub fn to_partial(self) -> PartialKeyPath<Root>
Convert to PartialKeyPath (hides Value type)
Sourcepub fn to(self) -> PartialKeyPath<Root>
pub fn to(self) -> PartialKeyPath<Root>
Alias for to_partial() - converts to PartialKeyPath
Trait Implementations§
Source§impl<Root, Value, F> WithContainer<Root, Value> for KeyPath<Root, Value, F>
impl<Root, Value, F> WithContainer<Root, Value> for KeyPath<Root, Value, F>
Source§fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
fn with_arc<Callback, R>(&self, arc: &Arc<Root>, f: Callback) -> R
Source§fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
fn with_box<Callback, R>(&self, boxed: &Box<Root>, f: Callback) -> R
Source§fn with_box_mut<Callback, R>(&self, _boxed: &mut Box<Root>, _f: Callback) -> Rwhere
Callback: FnOnce(&mut Value) -> R,
fn with_box_mut<Callback, R>(&self, _boxed: &mut Box<Root>, _f: Callback) -> Rwhere
Callback: FnOnce(&mut Value) -> R,
Source§fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
fn with_rc<Callback, R>(&self, rc: &Rc<Root>, f: Callback) -> R
Source§fn with_result<Callback, R, E>(
&self,
result: &Result<Root, E>,
f: Callback,
) -> Option<R>
fn with_result<Callback, R, E>( &self, result: &Result<Root, E>, f: Callback, ) -> Option<R>
Source§fn with_result_mut<Callback, R, E>(
&self,
_result: &mut Result<Root, E>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_result_mut<Callback, R, E>(
&self,
_result: &mut Result<Root, E>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Source§fn with_option<Callback, R>(
&self,
option: &Option<Root>,
f: Callback,
) -> Option<R>
fn with_option<Callback, R>( &self, option: &Option<Root>, f: Callback, ) -> Option<R>
Source§fn with_option_mut<Callback, R>(
&self,
_option: &mut Option<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_option_mut<Callback, R>(
&self,
_option: &mut Option<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Source§fn with_refcell<Callback, R>(
&self,
refcell: &RefCell<Root>,
f: Callback,
) -> Option<R>
fn with_refcell<Callback, R>( &self, refcell: &RefCell<Root>, f: Callback, ) -> Option<R>
Source§fn with_refcell_mut<Callback, R>(
&self,
_refcell: &RefCell<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_refcell_mut<Callback, R>(
&self,
_refcell: &RefCell<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Source§fn with_mutex<Callback, R>(&self, mutex: &Mutex<Root>, f: Callback) -> Option<R>
fn with_mutex<Callback, R>(&self, mutex: &Mutex<Root>, f: Callback) -> Option<R>
Source§fn with_mutex_mut<Callback, R>(
&self,
_mutex: &mut Mutex<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_mutex_mut<Callback, R>(
&self,
_mutex: &mut Mutex<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Source§fn with_rwlock<Callback, R>(
&self,
rwlock: &RwLock<Root>,
f: Callback,
) -> Option<R>
fn with_rwlock<Callback, R>( &self, rwlock: &RwLock<Root>, f: Callback, ) -> Option<R>
Source§fn with_rwlock_mut<Callback, R>(
&self,
_rwlock: &mut RwLock<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_rwlock_mut<Callback, R>(
&self,
_rwlock: &mut RwLock<Root>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Source§fn with_arc_rwlock<Callback, R>(
&self,
arc_rwlock: &Arc<RwLock<Root>>,
f: Callback,
) -> Option<R>
fn with_arc_rwlock<Callback, R>( &self, arc_rwlock: &Arc<RwLock<Root>>, f: Callback, ) -> Option<R>
Source§fn with_arc_rwlock_mut<Callback, R>(
&self,
_arc_rwlock: &Arc<RwLock<Root>>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
fn with_arc_rwlock_mut<Callback, R>(
&self,
_arc_rwlock: &Arc<RwLock<Root>>,
_f: Callback,
) -> Option<R>where
Callback: FnOnce(&mut Value) -> R,
Auto Trait Implementations§
impl<Root, Value, F> Freeze for KeyPath<Root, Value, F>where
F: Freeze,
impl<Root, Value, F> RefUnwindSafe for KeyPath<Root, Value, F>
impl<Root, Value, F> Send for KeyPath<Root, Value, F>
impl<Root, Value, F> Sync for KeyPath<Root, Value, F>
impl<Root, Value, F> Unpin for KeyPath<Root, Value, F>
impl<Root, Value, F> UnwindSafe for KeyPath<Root, Value, F>
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)