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

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

A variant of GetRef, reaching four 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 { pub city: String, pub street: Street }

  #[derive(GetRef)]
  pub struct Street { pub number: u16, pub name: String }

 let john_doe = Employee {
     name: String::from("John Doe"),
     company: Company {
         name: String::from("Acme Corporation"),
         address: Address {
                 city: String::from("London"),
                 street: Street {
                     number: 23,
                     name: String::from("High street"),
                 }
             },
         }
     };

 //                      Level 1   Level 2   Level 3 Level 4     Parent type
 //                         |         |        |       |           |
 impl<'a> GetRefFourth<'a, Company, Address, Street, String> for Employee {}

 assert_eq!("High street", john_doe.get_ref_fourth().as_str());

Provided methods

fn get_ref_fourth(&'a self) -> &'a LevelFour

Loading content...

Implementors

Loading content...