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

pub trait ModifyFifth<LevelOne, LevelTwo, LevelThree, LevelFour, LevelFive> where
    LevelFour: Modify<LevelFive>,
    LevelThree: Modify<LevelFour>,
    LevelTwo: Modify<LevelThree>,
    LevelOne: Modify<LevelTwo>,
    Self: Modify<LevelOne> + Sized
{ fn modify_fifth(self, f: impl FnOnce(LevelFive) -> LevelFive) -> Self { ... } }

A variant of Modify, reaching five levels deep in the data structure.

Examples

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

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

  #[derive(Get, Modify)]
  pub struct Address { pub city: String, pub street: Street }

  #[derive(Get, Modify)]
  pub struct Street { pub number: StreetNumber, pub name: String }

  #[derive(Get, Modify)]
  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 ModifyFifth<Company, Address, Street, StreetNumber, u16> for Employee {}
 impl GetFifth<Company, Address, Street, StreetNumber, u16> for Employee {}

 let john_doe_new_number = john_doe.modify_fifth(|num: u16| num * 10);

 assert_eq!(230, john_doe_new_number.get_fifth());

Provided methods

fn modify_fifth(self, f: impl FnOnce(LevelFive) -> LevelFive) -> Self

Loading content...

Implementations on Foreign Types

impl<LevelOne, LevelTwo, LevelThree, LevelFour, LevelFive> ModifyFifth<LevelOne, LevelTwo, LevelThree, LevelFour, LevelFive> for Option<LevelOne> where
    LevelOne: Modify<LevelTwo>,
    LevelTwo: Modify<LevelThree>,
    LevelThree: Modify<LevelFour>,
    LevelFour: Modify<LevelFive>, 
[src]

fn modify_fifth(self, f: impl FnOnce(LevelFive) -> LevelFive) -> Self[src]

Loading content...

Implementors

Loading content...