[][src]Trait structural::field::IntoField

pub trait IntoField<FieldName>: GetField<FieldName> {
    fn into_field_(self, field_name: FieldName) -> Self::Ty
    where
        Self: Sized
;
fn box_into_field_(self: Box<Self>, field_name: FieldName) -> Self::Ty; }

Converts this type into its FieldName field.

Safety

While this trait is not unsafe, implementors ought not mutate fields inside accessor trait impls.

Mutating fields is only advisable if those fields don't have field accessor impls.

Features

If you disable the default feature,and don't enable the "alloc" feature, you must implement the box_into_field_ method using the z_impl_box_into_field_method macro, this trait's manual implementation example shows how you can use the macro.

Usage as Bound Example

use structural::{StructuralExt,IntoField,FP,fp};
use structural::for_examples::{Struct2,Struct3};

fn example<T>(this: T)
where
    T: Copy + IntoField<FP!(foo), Ty=Option<i8>> + IntoField<FP!(bar), Ty=&'static str>
{
    assert_eq!( this.field_(fp!(foo)), &None );
    assert_eq!( this.field_(fp!(bar)), &"great" );
    assert_eq!( this.fields(fp!(foo,bar)), (&None, &"great") );
    assert_eq!( this.cloned_fields(fp!(foo,bar)), (None, "great") );

    // This can't be called with `IntoField` you need `IntoFieldMut` for that.
    // assert_eq!( this.field_mut(fp!(bar)), &mut "great" );

    assert_eq!( this.into_field(fp!(foo)), None );
    assert_eq!( this.into_field(fp!(bar)), "great" );
}

example(Struct2{ foo:None, bar: "great" });
example(Struct3{ foo:None, bar: "great", baz:5 });

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::{FieldType,GetField,IntoField,Structural,FP};

struct Huh<T>{
    value:T,
}


impl<T> Structural for Huh<T>{}

impl<T> FieldType<FP!(value)> for Huh<T>{
    type Ty=T;
}

impl<T> GetField<FP!(value)> for Huh<T>{
    fn get_field_(&self,_:FP!(value))->&Self::Ty{
        &self.value
    }
}

impl<T> IntoField<FP!(value)> for Huh<T>{
    fn into_field_(self,_:FP!(value))->Self::Ty{
        self.value
    }

    // You must use this, even in crates that don't enable the "alloc" feature
    // (the "alloc" feature is enabled by default),
    // since other crates that depend on structural might enable the feature.
    structural::z_impl_box_into_field_method!{field_tstr=FP!(value)}
}

Required methods

fn into_field_(self, field_name: FieldName) -> Self::Ty where
    Self: Sized

Converts self into the field.

fn box_into_field_(self: Box<Self>, field_name: FieldName) -> Self::Ty

Converts a boxed self into the field.

Features

This method is defined conditional on the "alloc" feature, read here for more details.

Loading content...

Implementations on Foreign Types

impl<T, P> IntoField<P> for [T; 0] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 1] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 2] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 3] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 4] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 5] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 6] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 7] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 8] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 9] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 10] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 11] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 12] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 13] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 14] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 15] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 16] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 17] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 18] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 19] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 20] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 21] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 22] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 23] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 24] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 25] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 26] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 27] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 28] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 29] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 30] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 31] where
    P: IsPathForArray<Self>, 
[src]

impl<T, P> IntoField<P> for [T; 32] where
    P: IsPathForArray<Self>, 
[src]

impl<T> IntoField<TStr<__TS<(__s, __t, __a, __r, __t)>>> for Range<T>[src]

impl<T> IntoField<TStr<__TS<(__e, __n, __d)>>> for Range<T>[src]

impl<T> IntoField<TStr<__TS<(__s, __t, __a, __r, __t)>>> for RangeFrom<T>[src]

impl<T> IntoField<TStr<__TS<(__e, __n, __d)>>> for RangeTo<T>[src]

impl<T> IntoField<TStr<__TS<(__e, __n, __d)>>> for RangeToInclusive<T>[src]

impl<T> IntoField<TStr<__TS<(__s, __t, __a, __r, __t)>>> for RangeInclusive<T>[src]

impl<T> IntoField<TStr<__TS<(__e, __n, __d)>>> for RangeInclusive<T>[src]

impl<T, __F, __Ty> IntoField<__F> for ManuallyDrop<T> where
    T: Sized + IntoField<__F, Ty = __Ty>, 
[src]

impl<T: ?Sized, P> IntoField<P> for Box<T> where
    T: IntoField<P>, 
[src]

impl<C0> IntoField<TStr<__TS<(__0,)>>> for (C0,)[src]

impl<C0, C1> IntoField<TStr<__TS<(__0,)>>> for (C0, C1)[src]

impl<C0, C1> IntoField<TStr<__TS<(__1,)>>> for (C0, C1)[src]

impl<C0, C1, C2> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2)[src]

impl<C0, C1, C2> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2)[src]

impl<C0, C1, C2> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2)[src]

impl<C0, C1, C2, C3> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3)[src]

impl<C0, C1, C2, C3, C4> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5> IntoField<TStr<__TS<(__5,)>>> for (C0, C1, C2, C3, C4, C5)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__5,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6> IntoField<TStr<__TS<(__6,)>>> for (C0, C1, C2, C3, C4, C5, C6)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__5,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__6,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7> IntoField<TStr<__TS<(__7,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__5,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__6,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__7,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8> IntoField<TStr<__TS<(__8,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__0,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__1,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__2,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__3,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__4,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__5,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__6,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__7,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__8,)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9)[src]

impl<C0, C1, C2, C3, C4, C5, C6, C7, C8, C9> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__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> IntoField<TStr<__TS<(__1, __1)>>> for (C0, C1, C2, C3, C4, C5, C6, C7, C8, C9, C10, C11)[src]

Loading content...

Implementors

impl<T, V, F> IntoField<F> for VariantProxy<T, V> where
    T: IntoVariantField<V, F>,
    V: IsTStr
[src]

impl<T, __F, __Ty> IntoField<__F> for StrucWrapper<T> where
    T: Sized + IntoField<__F, Ty = __Ty>, 
[src]

Loading content...