[−][src]Trait photonix::focus::composites::SetFourth
A variant of Set
, 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, Set)] 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 SetFourth<Company, Address, Street, String> for Employee {} impl GetFourth<Company, Address, Street, String> for Employee {} let john_at_new_street = john_doe.set_fourth(String::from("Low street")); assert_eq!("Low street", john_at_new_street.get_fourth().as_str());
Provided methods
fn set_fourth(self, new_value: LevelFour) -> Self
Implementations on Foreign Types
impl<LevelOne, LevelTwo, LevelThree, LevelFour> SetFourth<LevelOne, LevelTwo, LevelThree, LevelFour> for Option<LevelOne> where
LevelOne: Modify<LevelTwo>,
LevelTwo: Modify<LevelThree>,
LevelThree: Set<LevelFour>,
[src]
LevelOne: Modify<LevelTwo>,
LevelTwo: Modify<LevelThree>,
LevelThree: Set<LevelFour>,