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>,
},
}
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
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>
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_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
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 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
Trait Implementations§
Auto Trait Implementations§
impl<Root, Value> Freeze for KeyPaths<Root, Value>
impl<Root, Value> !RefUnwindSafe for KeyPaths<Root, Value>
impl<Root, Value> !Send for KeyPaths<Root, Value>
impl<Root, Value> !Sync for KeyPaths<Root, Value>
impl<Root, Value> Unpin for KeyPaths<Root, Value>
impl<Root, Value> !UnwindSafe for KeyPaths<Root, Value>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more