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

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

A variant of Get, reaching three 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 }

 #[derive(Get)]
 pub struct Address(String);

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

 assert_eq!("4 Foo Road, Bar City", company_address.as_str());

Provided methods

fn get_third(self) -> LevelThree

Loading content...

Implementors

Loading content...