[][src]Trait structural::field::IntoVariantFieldMut

pub trait IntoVariantFieldMut<V, F>: GetVariantFieldMut<V, F> + IntoVariantField<V, F> { }

A bound for shared,mutable,and by-value access to the field F inside of the V variant.

The V and F type parameters are expected to be TStr.

Every instance of "the F field"/"the V variant" in the docs mean "in the field/variant named by the F/V type parameter"

Example

use structural::field::IntoVariantFieldMut;
use structural::for_examples::{Bomb,WithBoom};
use structural::{StructuralExt,TS,fp};

fn example<T>(mut this: T)
where
    T: IntoVariantFieldMut<TS!(Boom),TS!(a),Ty= &'static str>+
       IntoVariantFieldMut<TS!(Boom),TS!(b),Ty= &'static [u16]>,
{
    assert_eq!( this.is_variant(fp!(Boom)), true );

    assert_eq!( this.field_(fp!(::Boom.a)), Some(&"Because.") );

    assert_eq!( this.cloned_fields(fp!(::Boom=>a,b)), Some(( "Because.", &[13,21][..] )) );

    assert_eq!( this.fields(fp!(::Boom=>a,b)), Some(( &"Because.", &&[13,21][..] )) );

    assert_eq!( this.field_mut(fp!(::Boom.a)), Some(&mut "Because.") );

    assert_eq!( this.fields_mut(
        fp!(::Boom=>a,b)),
        Some(( &mut "Because.", &mut &[13,21][..] )),
    );

    assert_eq!( this.into_field(fp!(::Boom.a)), Some("Because.") );
}

example(WithBoom::Boom{ a:"Because.", b:&[13,21] });
example(Bomb::Boom{ a:"Because.", b:&[13,21] });

Implementors

impl<This: ?Sized, V, F> IntoVariantFieldMut<V, F> for This where
    This: GetVariantFieldMut<V, F> + IntoVariantField<V, F>, 
[src]

Loading content...