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

pub trait GetRefThird<'a, LevelOne, LevelTwo, LevelThree> where
    LevelTwo: GetRef<LevelThree> + 'a,
    LevelOne: GetRef<LevelTwo> + 'a,
    Self: GetRef<LevelOne> + 'a, 
{ fn get_ref_third(&'a self) -> &'a LevelThree { ... } }

A variant of GetRef, reaching three levels deep in the data structure.

Examples

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

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

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

 //                      Level 1    Level 2  Level 3   Parent type
 //                          |        |        |           |
 impl<'a> GetRefThird<'a, 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_ref_third();

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

Provided methods

fn get_ref_third(&'a self) -> &'a LevelThree

Loading content...

Implementors

Loading content...