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

pub trait SetThird<LevelOne, LevelTwo, LevelThree> where
    LevelTwo: Set<LevelThree>,
    LevelOne: Modify<LevelTwo>,
    Self: Modify<LevelOne> + Sized
{ fn set_third(self, new_value: LevelThree) -> Self { ... } }

A variant of Set, reaching three 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, Set)]
 pub struct Address(String);

 //            Level 1    Level 2  Level 3   Parent type
 //                |        |        |           |
 impl SetThird<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.set_third(String::from("3 Baz Road, Qux City"));

 assert_eq!("3 Baz Road, Qux City", john_doe_new.get_third().as_str());

Provided methods

fn set_third(self, new_value: LevelThree) -> Self

Loading content...

Implementations on Foreign Types

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

fn set_third(self, new_value: LevelThree) -> Self[src]

Loading content...

Implementors

Loading content...