Trait GetFieldMut

Source
pub trait GetFieldMut
where Self: Sized,
{ // Required methods 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>; }
Expand description

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

Required Methods§

Source

fn get_field_mut<T>(&mut self, fr: FieldRef<Self, T>) -> &mut T

§Examples
use field_ref::{GetFieldMut, field_ref_of};

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);
Source

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>,

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S: Sized> GetFieldMut for S