pub struct OptionalKeyPath<Root, Value, F>{ /* private fields */ }Implementations§
Source§impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
pub fn new(getter: F) -> Self
pub fn get<'r>(&self, root: &'r Root) -> Option<&'r Value>
pub fn then<SubValue, G>( self, next: OptionalKeyPath<Value, SubValue, G>, ) -> OptionalKeyPath<Root, SubValue, impl for<'r> Fn(&'r Root) -> Option<&'r SubValue>>
pub fn for_box<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_arc<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
pub fn for_rc<Target>(
self,
) -> OptionalKeyPath<Root, Target, impl for<'r> Fn(&'r Root) -> Option<&'r Target> + 'static>where
Value: Deref<Target = Target> + 'static,
F: 'static,
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 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
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_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 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_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_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> OptionalKeyPath<Root, Value, F>
impl<Root, Value, F> OptionalKeyPath<Root, Value, F>
Sourcepub fn to_partial(self) -> PartialOptionalKeyPath<Root>
pub fn to_partial(self) -> PartialOptionalKeyPath<Root>
Convert to PartialOptionalKeyPath (hides Value type)
Sourcepub fn to_any(self) -> AnyKeyPath
pub fn to_any(self) -> AnyKeyPath
Convert to AnyKeyPath (hides both Root and Value types)
Sourcepub fn to(self) -> PartialOptionalKeyPath<Root>
pub fn to(self) -> PartialOptionalKeyPath<Root>
Convert to PartialOptionalKeyPath (alias for to_partial())
Trait Implementations§
Source§impl<Root: Clone, Value: Clone, F> Clone for OptionalKeyPath<Root, Value, F>
impl<Root: Clone, Value: Clone, F> Clone for OptionalKeyPath<Root, Value, F>
Source§fn clone(&self) -> OptionalKeyPath<Root, Value, F>
fn clone(&self) -> OptionalKeyPath<Root, Value, F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more