Trait field_ref::GetField [] [src]

pub trait GetField where
    Self: Sized
{ fn get_field<T>(&self, fr: FieldRef<Self, T>) -> &T;
fn try_get_field<'x, FR, T>(&'x self, fr: FR) -> Option<&'x T>
    where
        FR: OptionFieldRef<'x, Input = Self, Output = T>
; }

A trait to obtain a value to which FieldRef references via description like obj.get_field(field_ref).

Required Methods

Examples

#[macro_use]
extern crate field_ref;

use field_ref::GetField;

struct Foo(u32, u32, f64);

let fr = field_ref_of!(Foo => 1);
let foo = Foo(10, 20, 0.5);
assert_eq!(foo.get_field(fr), &20);

Implementors