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

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

A variant of GetRef, reaching two 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 }

 pub struct Address(String);

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

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

Provided methods

fn get_ref_second(&'a self) -> &'a LevelTwo

Loading content...

Implementors

Loading content...