Struct keypath::KeyPath [−][src]
pub struct KeyPath<Root: ?Sized, Value: 'static> { /* fields omitted */ }
Expand description
A non-fallible keypath.
Implementations
Create a new KeyPath
by combining two routes.
The final type of the first route must be the first type of the second
route; assuming both paths were created with the keypath!
macro,
the resulting path must be valid.
Examples
use keypath::{Keyable, KeyPath, keypath}; #[derive(Keyable)] struct Person { name: String, friends: Vec<String>, size: Size, } #[derive(Keyable)] struct Size { big: bool, heft: u8, } let mut person = Person { name: "coco".into(), friends: vec!["eli".into(), "nico".into(), "yaya".into()], size: Size { big: false, heft: 45 } }; let size = keypath!(Person.size); let heft = keypath!(Size.heft); let combined = size.append(&heft); assert_eq!(person[&combined], 45);
Trait Implementations
Auto Trait Implementations
impl<Root: ?Sized, Value> RefUnwindSafe for KeyPath<Root, Value> where
Root: RefUnwindSafe,
Value: RefUnwindSafe,
impl<Root: ?Sized, Value> UnwindSafe for KeyPath<Root, Value> where
Root: UnwindSafe,
Value: UnwindSafe,