[−][src]Trait photonix::focus::composites::ModifySecond
A variant of Modify
, reaching two 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 } pub struct Address(String); // Level 1 Level 2 Parent type // | | | impl ModifySecond<Company, String> for Employee {} impl GetSecond<Company, 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_second(|name| name.replace("Corporation", "Inc")); assert_eq!("Acme Inc", john_doe_new.get_second().as_str());
Provided methods
fn modify_second(self, f: impl FnOnce(LevelTwo) -> LevelTwo) -> Self
Implementations on Foreign Types
impl<LevelOne, LevelTwo> ModifySecond<LevelOne, LevelTwo> for Option<LevelOne> where
LevelOne: Modify<LevelTwo>,
[src]
LevelOne: Modify<LevelTwo>,