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

pub trait GetSecond<LevelOne, LevelTwo> where
    LevelOne: Get<LevelTwo>,
    Self: Get<LevelOne> + Sized
{ fn get_second(self) -> LevelTwo { ... } }

A variant of Get, reaching two levels deep in the data structure.

Examples

 #[derive(Get)]
 pub struct Employee { pub name: String, pub company: Company }

 #[derive(Get)]
 pub struct Company { pub name: String, pub address: Address }

 pub struct Address(String);

 //             Level 1   Level 2    Parent type
 //               |          |           |
 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 company_name = john_doe.get_second();

 assert_eq!("Acme Corporation", company_name.as_str());

Provided methods

fn get_second(self) -> LevelTwo

Loading content...

Implementors

Loading content...