Trait field_ref::GetFieldMut [] [src]

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

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

Required Methods

Examples

#[macro_use]
extern crate field_ref;

use field_ref::GetFieldMut;

struct Foo(u32, u32, f64);

let fr = field_ref_of!(Foo => 1);
let mut foo = Foo(10, 20, 0.5);
*foo.get_field_mut(fr) = 30;
assert_eq!(foo.1, 30);

Implementors