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

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

A variant of Get, reaching five 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: StreetNumber, pub name: String }

  #[derive(Get)]
  pub struct StreetNumber(u16);

 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: StreetNumber(23),
                     name: String::from("High street"),
                 }
             },
         }
     };

 //            Level 1   Level 2   Level 3 Level     Level 5   Parent type
 //               |         |        |       |           |         |
 impl GetFifth<Company, Address, Street, StreetNumber, u16> for Employee {}

 assert_eq!(23, john_doe.get_fifth());

Provided methods

fn get_fifth(self) -> LevelFive

Loading content...

Implementors

Loading content...