[−][src]Trait photonix::focus::composites::SetSecond
A variant of Set
, reaching two levels deep in the data structure.
Examples
#[derive(Get, Modify)] pub struct Employee { pub name: String, pub company: Company } #[derive(Get, Set)] pub struct Company { pub name: String, pub address: Address } pub struct Address(String); // Level 1 Level 2 Parent type // | | | impl SetSecond<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.set_second(String::from("Evil Corp")); assert_eq!("Evil Corp", john_doe_new.get_second().as_str());
Provided methods
fn set_second(self, new_value: LevelTwo) -> Self
Implementations on Foreign Types
impl<LevelOne, LevelTwo> SetSecond<LevelOne, LevelTwo> for Option<LevelOne> where
LevelOne: Set<LevelTwo>,
[src]
LevelOne: Set<LevelTwo>,