[][src]Trait photonix::focus::Get

pub trait Get<Value> {
    fn get(self) -> Value;
}

Returns the target field of a container (struct) by value, consumes the container (unless it implements Copy).

Auto-derive creates the implementation for all fields, works for structs (both with named and unnamed fields) if

  • all fields have concrete types,
  • all field types are different.

Examples

 #[derive(Get)]
 pub struct Person {
     pub name: String,
     pub age: u8,
 }

 let joe = || Person { name: String::from("Joe"), age: 42 };

 assert_eq!(42u8, joe().get());

 let joe_name: String = joe().get();

 assert_eq!("Joe", joe_name.as_str());

Required methods

fn get(self) -> Value

Loading content...

Implementors

Loading content...