[][src]Trait photonix::focus::composites::ModifyThird

pub trait ModifyThird<LevelOne, LevelTwo, LevelThree> where
    LevelTwo: Modify<LevelThree>,
    LevelOne: Modify<LevelTwo>,
    Self: Modify<LevelOne> + Sized
{ fn modify_third(self, f: impl FnOnce(LevelThree) -> LevelThree) -> Self { ... } }

A variant of Modify, reaching three levels deep in the data structure.

 #[derive(Get, Modify)]
 pub struct Employee { pub name: String, pub company: Company }

 #[derive(Get, Modify)]
 pub struct Company { pub name: String, pub address: Address }

 #[derive(Get, Modify)]
 pub struct Address(String);

 //            Level 1    Level 2  Level 3   Parent type
 //                |        |        |           |
 impl ModifyThird<Company, Address, String> for Employee {}
 impl GetThird<Company, Address, String> for Employee {}

 let john_doe = Employee {
     name: String::from("John Doe"),
     company: Company {
         name: String::from("Acme Corporation"),
         address: Address(String::from("4 Foo Road, Bar City")),
         }
     };

 let john_doe_new = john_doe.modify_third(|address| address.replace("4", "5"));

 assert_eq!("5 Foo Road, Bar City", john_doe_new.get_third().as_str());

Provided methods

fn modify_third(self, f: impl FnOnce(LevelThree) -> LevelThree) -> Self

Loading content...

Implementations on Foreign Types

impl<LevelOne, LevelTwo, LevelThree> ModifyThird<LevelOne, LevelTwo, LevelThree> for Option<LevelOne> where
    LevelOne: Modify<LevelTwo>,
    LevelTwo: Modify<LevelThree>, 
[src]

fn modify_third(self, f: impl FnOnce(LevelThree) -> LevelThree) -> Self[src]

Loading content...

Implementors

Loading content...