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

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

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

  #[derive(Get)]
  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 GetFourth<Company, Address, Street, String> for Employee {}

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

Provided methods

fn get_fourth(self) -> LevelFour

Loading content...

Implementors

Loading content...