[−][src]Trait photonix::focus::composites::ModifyFourth
A variant of Modify
, reaching four levels deep in the data structure.
Examples
#[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 { pub city: String, pub street: Street } #[derive(Get, Modify)] pub struct Street { pub number: u16, pub name: String } let john_doe = Employee { name: String::from("John Doe"), company: Company { name: String::from("Acme Corporation"), address: Address { city: String::from("London"), street: Street { number: 23, name: String::from("High street"), } }, } }; // Level 1 Level 2 Level 3 Level 4 Parent type // | | | | | impl ModifyFourth<Company, Address, Street, String> for Employee {} impl GetFourth<Company, Address, Street, String> for Employee {} let john_at_new_street = john_doe.modify_fourth(|street_name| street_name.replace("street", "road")); assert_eq!("High road", john_at_new_street.get_fourth().as_str());
Provided methods
fn modify_fourth(self, f: impl FnOnce(LevelFour) -> LevelFour) -> Self
Implementations on Foreign Types
impl<LevelOne, LevelTwo, LevelThree, LevelFour> ModifyFourth<LevelOne, LevelTwo, LevelThree, LevelFour> for Option<LevelOne> where
LevelOne: Modify<LevelTwo>,
LevelTwo: Modify<LevelThree>,
LevelThree: Modify<LevelFour>,
[src]
LevelOne: Modify<LevelTwo>,
LevelTwo: Modify<LevelThree>,
LevelThree: Modify<LevelFour>,