[][src]Trait structural::field_traits::GetFieldMut

pub unsafe trait GetFieldMut<FieldName>: GetField<FieldName> {
    fn get_field_mut_(&mut self) -> &mut Self::Ty;
unsafe fn get_field_mutref(
        ptr: MutRef<()>,
        getter: GetFieldMutRefFn<FieldName, Self::Ty>
    ) -> &mut Self::Ty
    where
        Self: Sized
;
fn as_mutref(&mut self) -> MutRef<()>;
fn get_field_mutref_func(&self) -> GetFieldMutRefFn<FieldName, Self::Ty>; }

Allows accessing the FieldName field mutably.

Usage as Bound Example

This example demonstrates how you can use this trait as a bound.

If you have a lot of field accessor bounds you could use structural_alias macro to alias those bounds and use that alias instead.

use structural::{GetFieldMut,GetFieldExt,TI,ti};
 
fn take_value<T,V>(this:&mut T)->V
where
    T:GetFieldMut<TI!(v a l u e), Ty=V>,
    V:Default,
{
    std::mem::replace( this.field_mut(ti!(value)), Default::default() )
}

#[derive(structural::Structural)]
struct Huh<T>{
    #[struc(access="mut")]
    value:T,
}
 
fn main(){
    let mut this=Huh{value:"Hello, World!"};
    assert_eq!(take_value(&mut this),"Hello, World!");
    assert_eq!(this.value,"");
}

Manual Implementation Example

While this trait is intended to be implemented using the Structural derive macro, you can manually implement it like this:

use structural::{
    GetField,GetFieldMut,Structural,TI,TList,
    structural_trait::{FieldInfo,TField},
    mut_ref::MutRef,
    impl_structural_dyn,
};

struct Huh<T>{
    value:T,
}

impl<T> Structural for Huh<T>{
    const FIELDS:&'static[FieldInfo]=&[FieldInfo::not_renamed("value")];

    type Fields=TList![ TField<TI!(v a l u e),T> ];
}

impl_structural_dyn!{ impl[T] Huh<T> }

impl<T> GetField<TI!(v a l u e)> for Huh<T>{
    type Ty=T;

    fn get_field_(&self)->&Self::Ty{
        &self.value
    }
}

unsafe impl<T> GetFieldMut<TI!(v a l u e)> for Huh<T>{
    fn get_field_mut_(&mut self)->&mut Self::Ty{
        &mut self.value
    }
    structural::unsafe_impl_get_field_raw_mut_method!{
        Self,
        field_name=value,
        name_generic=TI!(v a l u e)
    }
}

Required methods

fn get_field_mut_(&mut self) -> &mut Self::Ty

Accesses the FieldName field by mutable reference.

unsafe fn get_field_mutref(
    ptr: MutRef<()>,
    getter: GetFieldMutRefFn<FieldName, Self::Ty>
) -> &mut Self::Ty where
    Self: Sized

Gets a mutable reference to the field.

Safety

For the ptr argument,you must pass the return value of the as_mutref method for this field.

For the getter argument,you must pass the return value of the get_field_mutref_func method for this field.

The getter argument is necessary for boxed trait objects.

fn as_mutref(&mut self) -> MutRef<()>

Gets a pointer to the struct that contains this field.

Implementors must return a pointer to the same type that GetFieldMut::get_field_mutref casts the pointer to.

fn get_field_mutref_func(&self) -> GetFieldMutRefFn<FieldName, Self::Ty>

Gets the get_field_mutref associated function as a function pointer.

Loading content...

Implementations on Foreign Types

impl<C0> GetFieldMut<TString<(_0,)>> for (C0,)[src]

impl<C0, C1> GetFieldMut<TString<(_0,)>> for (C0, C1)[src]

impl<C0, C1> GetFieldMut<TString<(_1,)>> for (C0, C1)[src]

impl<C0, C1, C2> GetFieldMut<TString<(_0,)>> for (C0, C1, C2)[src]

impl<C0, C1, C2> GetFieldMut<TString<(_1,)>> for (C0, C1, C2)[src]

impl<C0, C1, C2> GetFieldMut<TString<(_2,)>> for (C0, C1, C2)[src]

impl<C0, C1, C2, C3> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3, C4> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> GetFieldMut<TString<(_7,)>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_7,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> GetFieldMut<TString<(_8,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_7,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_8,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> GetFieldMut<TString<(_9,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_7,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_8,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_9,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10> GetFieldMut<TString<(_1, _0)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_0,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_1,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_2,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_3,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_4,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_5,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_6,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_7,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_8,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_9,)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_1, _0)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11> GetFieldMut<TString<(_1, _1)>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

impl<T> GetFieldMut<TString<(_s, _t, _a, _r, _t)>> for Range<T>[src]

impl<T> GetFieldMut<TString<(_e, _n, _d)>> for Range<T>[src]

impl<T> GetFieldMut<TString<(_s, _t, _a, _r, _t)>> for RangeFrom<T>[src]

impl<T> GetFieldMut<TString<(_e, _n, _d)>> for RangeTo<T>[src]

impl<T> GetFieldMut<TString<(_e, _n, _d)>> for RangeToInclusive<T>[src]

impl<T, __FieldName> GetFieldMut<__FieldName> for ManuallyDrop<T> where
    T: GetFieldMut<__FieldName>, 
[src]

impl<P, __FieldName> GetFieldMut<__FieldName> for Pin<P> where
    P::Target: GetFieldMut<__FieldName>,
    P: DerefMut,
    P::Target: Unpin,
    P: Deref,
    P::Target: Sized
[src]

impl<T: ?Sized, FieldName, Ty> GetFieldMut<FieldName> for Box<T> where
    T: GetFieldMut<FieldName, Ty = Ty>, 
[src]

fn get_field_mut_(&mut self) -> &mut Self::Ty[src]

Accesses the FieldName field by mutable reference.

Loading content...

Implementors

Loading content...