pub enum KeyPaths<Root, Value> {
Readable(Rc<dyn for<'a> Fn(&'a Root) -> &'a Value>),
ReadableEnum {
extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>,
embed: Rc<dyn Fn(Value) -> Root>,
},
FailableReadable(Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>),
Writable(Rc<dyn for<'a> Fn(&'a mut Root) -> &'a mut Value>),
FailableWritable(Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>),
WritableEnum {
extract: Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>,
extract_mut: Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>,
embed: Rc<dyn Fn(Value) -> Root>,
},
Owned(Rc<dyn Fn(Root) -> Value>),
FailableOwned(Rc<dyn Fn(Root) -> Option<Value>>),
}Expand description
Go to examples section to see the implementations
Variants§
Readable(Rc<dyn for<'a> Fn(&'a Root) -> &'a Value>)
ReadableEnum
FailableReadable(Rc<dyn for<'a> Fn(&'a Root) -> Option<&'a Value>>)
Writable(Rc<dyn for<'a> Fn(&'a mut Root) -> &'a mut Value>)
FailableWritable(Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>)
WritableEnum
Fields
extract_mut: Rc<dyn for<'a> Fn(&'a mut Root) -> Option<&'a mut Value>>Owned(Rc<dyn Fn(Root) -> Value>)
FailableOwned(Rc<dyn Fn(Root) -> Option<Value>>)
Implementations§
Source§impl<Root, Value> KeyPaths<Root, Value>
impl<Root, Value> KeyPaths<Root, Value>
pub fn readable( get: impl for<'a> Fn(&'a Root) -> &'a Value + 'static, ) -> KeyPaths<Root, Value>
pub fn writable( get_mut: impl for<'a> Fn(&'a mut Root) -> &'a mut Value + 'static, ) -> KeyPaths<Root, Value>
pub fn failable_readable( get: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, ) -> KeyPaths<Root, Value>
pub fn failable_writable( get_mut: impl for<'a> Fn(&'a mut Root) -> Option<&'a mut Value> + 'static, ) -> KeyPaths<Root, Value>
pub fn readable_enum( embed: impl Fn(Value) -> Root + 'static, extract: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, ) -> KeyPaths<Root, Value>
pub fn writable_enum( embed: impl Fn(Value) -> Root + 'static, extract: impl for<'a> Fn(&'a Root) -> Option<&'a Value> + 'static, extract_mut: impl for<'a> Fn(&'a mut Root) -> Option<&'a mut Value> + 'static, ) -> KeyPaths<Root, Value>
pub fn owned(get: impl Fn(Root) -> Value + 'static) -> KeyPaths<Root, Value>
pub fn failable_owned( get: impl Fn(Root) -> Option<Value> + 'static, ) -> KeyPaths<Root, Value>
pub fn owned_writable( get: impl Fn(Root) -> Value + 'static, ) -> KeyPaths<Root, Value>
pub fn failable_owned_writable( get: impl Fn(Root) -> Option<Value> + 'static, ) -> KeyPaths<Root, Value>
Source§impl<Root, Value> KeyPaths<Root, Value>
impl<Root, Value> KeyPaths<Root, Value>
Sourcepub fn get<'a>(&'a self, root: &'a Root) -> Option<&'a Value>
pub fn get<'a>(&'a self, root: &'a Root) -> Option<&'a Value>
Get an immutable reference if possible
Sourcepub fn get_ref<'a, 'b>(&'a self, root: &'b &Root) -> Option<&'b Value>where
'a: 'b,
pub fn get_ref<'a, 'b>(&'a self, root: &'b &Root) -> Option<&'b Value>where
'a: 'b,
Get an immutable reference when Root is itself a reference (&T) This enables using keypaths with collections of references like Vec<&T>
Sourcepub fn get_mut<'a>(&'a self, root: &'a mut Root) -> Option<&'a mut Value>
pub fn get_mut<'a>(&'a self, root: &'a mut Root) -> Option<&'a mut Value>
Get a mutable reference if possible
Sourcepub fn get_mut_ref<'a, 'b>(
&'a self,
root: &'b mut &mut Root,
) -> Option<&'b mut Value>where
'a: 'b,
pub fn get_mut_ref<'a, 'b>(
&'a self,
root: &'b mut &mut Root,
) -> Option<&'b mut Value>where
'a: 'b,
Get a mutable reference when Root is itself a mutable reference (&mut T) This enables using writable keypaths with collections of mutable references
Sourcepub fn for_arc(self) -> KeyPaths<Arc<Root>, Value>where
Root: 'static,
Value: 'static,
pub fn for_arc(self) -> KeyPaths<Arc<Root>, Value>where
Root: 'static,
Value: 'static,
Adapt this keypath to work with Arc
Sourcepub fn for_box(self) -> KeyPaths<Box<Root>, Value>where
Root: 'static,
Value: 'static,
pub fn for_box(self) -> KeyPaths<Box<Root>, Value>where
Root: 'static,
Value: 'static,
Adapt this keypath to work with Box
Sourcepub fn for_rc(self) -> KeyPaths<Rc<Root>, Value>where
Root: 'static,
Value: 'static,
pub fn for_rc(self) -> KeyPaths<Rc<Root>, Value>where
Root: 'static,
Value: 'static,
Adapt this keypath to work with Rc
pub fn embed(&self, value: Value) -> Option<Root>where
Value: Clone,
pub fn embed_mut(&self, value: Value) -> Option<Root>where
Value: Clone,
Sourcepub fn get_owned(self, root: Root) -> Value
pub fn get_owned(self, root: Root) -> Value
Get an owned value (primary method for owned keypaths)
Sourcepub fn get_failable_owned(self, root: Root) -> Option<Value>
pub fn get_failable_owned(self, root: Root) -> Option<Value>
Get an owned value with failable access
Sourcepub fn iter<'a, T>(
&'a self,
root: &'a Root,
) -> Option<<&'a Value as IntoIterator>::IntoIter>
pub fn iter<'a, T>( &'a self, root: &'a Root, ) -> Option<<&'a Value as IntoIterator>::IntoIter>
Iter over immutable references if Value: IntoIterator
Sourcepub fn iter_mut<'a, T>(
&'a self,
root: &'a mut Root,
) -> Option<<&'a mut Value as IntoIterator>::IntoIter>
pub fn iter_mut<'a, T>( &'a self, root: &'a mut Root, ) -> Option<<&'a mut Value as IntoIterator>::IntoIter>
Iter over mutable references if &mut Value: IntoIterator
Sourcepub fn into_iter<T>(
self,
root: Root,
) -> Option<<Value as IntoIterator>::IntoIter>where
Value: IntoIterator<Item = T> + Clone,
pub fn into_iter<T>(
self,
root: Root,
) -> Option<<Value as IntoIterator>::IntoIter>where
Value: IntoIterator<Item = T> + Clone,
Consume root and iterate if Value: IntoIterator