[][src]Struct structural::VariantName

pub struct VariantName<V> {
    pub name: V,
}

This allows accessing the V enum variant (by constructing a VariantProxy representing that variant).

This is the type that fp!(::Foo) constructs.
Note that fp!(::Foo.bar) constructs a VariantField instead.

The V type parameters is a TStr.

Construction

You can construct this using (not an exhaustive list):

  • fp macro,with fp!(::Foo)

  • The VariantName{name} struct literal

  • The new constructor.

  • The NEW associated constant,if V implements core_extensions::ConstDefault (reexported in structural::reexports::ConstDefault)

Example

use structural::{StructuralExt, fp, ts};
use structural::for_examples::Variants;
use structural::path::VariantName;

let mut foo=Variants::Foo(3,5);

{
    let proxy= foo.field_(fp!(::Foo)).unwrap();
    assert_eq!( proxy.field_(fp!(0)), &3 );
    assert_eq!( proxy.field_(fp!(1)), &5 );
}
assert_eq!( foo.field_(fp!(::Boom)), None );
 
{
    let proxy= foo.field_(VariantName::new(ts!(Foo))).unwrap();
    assert_eq!( proxy.field_(fp!(0)), &3 );
    assert_eq!( proxy.field_(fp!(1)), &5 );
}
assert_eq!( foo.field_(VariantName::new(ts!(Boom))), None );
 
 
{
    let proxy= foo.field_mut(fp!(::Foo)).unwrap();
    assert_eq!( proxy.field_mut(fp!(0)), &mut 3 );
    assert_eq!( proxy.field_mut(fp!(1)), &mut 5 );
}
assert_eq!( foo.field_mut(fp!(::Boom)), None );
 
{
    let proxy= foo.field_mut(VariantName::new(ts!(Foo))).unwrap();
    assert_eq!( proxy.field_mut(fp!(0)), &mut 3 );
    assert_eq!( proxy.field_mut(fp!(1)), &mut 5 );
}
assert_eq!( foo.field_mut(VariantName::new(ts!(Boom))), None );
 
 

Fields

name: V

The variant this accesses.

Implementations

impl<V> VariantName<V> where
    V: ConstDefault
[src]

pub const NEW: Self[src]

Constructs a VariantName.

impl<V> VariantName<V>[src]

pub const fn into_path(self) -> NestedFieldPath<(Self,)>[src]

Constructs a NestedFieldPath from this.

pub const fn into_set(self) -> FieldPathSet<(Self,), UniquePaths>[src]

Constructs a FieldPathSet from this.

impl<V> VariantName<V>[src]

pub fn new(name: V) -> Self[src]

Constructs a VariantName from name.

name is expected to be a ::structural::path::TStr.

Trait Implementations

impl<V: Clone> Clone for VariantName<V>[src]

impl<V> ConstDefault for VariantName<V> where
    V: ConstDefault
[src]

impl<V: Copy> Copy for VariantName<V>[src]

impl<T> Debug for VariantName<T>[src]

impl<V: Default> Default for VariantName<V>[src]

impl<T> Eq for VariantName<T>[src]

impl<T> IsMultiFieldPath for VariantName<T>[src]

type PathUniqueness = UniquePaths

Whether the paths in the set can contain duplicate paths. Read more

impl<V> IsSingleFieldPath for VariantName<V>[src]

impl<T> Ord for VariantName<T>[src]

impl<T> PartialEq<VariantName<T>> for VariantName<T>[src]

impl<T> PartialOrd<VariantName<T>> for VariantName<T>[src]

impl<This: ?Sized, S> RevFieldErr<This> for VariantName<TStr<S>> where
    This: IsVariant<TStr<S>>,
    S: 'static, 
[src]

type Err = FailedAccess

The error returned by rev_* methods. Read more

impl<This: ?Sized, S> RevFieldType<This> for VariantName<TStr<S>> where
    This: IsVariant<TStr<S>>,
    S: 'static, 
[src]

type Ty = VariantProxy<This, TStr<S>>

The type of the field.

impl<'a, This: ?Sized, S> RevGetFieldImpl<'a, This> for VariantName<TStr<S>> where
    This: 'a + IsVariant<TStr<S>>,
    S: 'static, 
[src]

impl<'a, This: ?Sized, S> RevGetFieldMutImpl<'a, This> for VariantName<TStr<S>> where
    This: 'a + IsVariant<TStr<S>>,
    S: 'static, 
[src]

impl<'a, This: ?Sized, T> RevGetMultiFieldImpl<'a, This> for VariantName<T> where
    Self: RevGetFieldImpl<'a, This>,
    This: 'a,
    RGFT<Self, This>: 'a,
    Result<&'a RGFT<Self, This>, RGFE<Self, This>>: 'a + NormalizeFields
[src]

type UnnormFields = (Result<&'a RGFT<Self, This>, RGFE<Self, This>>,)

A collection of Results<&'a _,_>s referencing fields.

impl<'a, This: ?Sized, T> RevGetMultiFieldMutImpl<'a, This> for VariantName<T> where
    Self: RevGetFieldMutImpl<'a, This>,
    This: 'a,
    RGFT<Self, This>: 'a,
    Result<&'a mut RGFT<Self, This>, RGFE<Self, This>>: NormalizeFields,
    Result<*mut RGFT<Self, This>, RGFE<Self, This>>: NormalizeFields
[src]

type UnnormFieldsMut = (Result<&'a mut RGFT<Self, This>, RGFE<Self, This>>,)

This is usually a tuple of Result<&mut _,E: IsFieldErr>s.

type UnnormFieldsRawMut = (Result<*mut RGFT<Self, This>, RGFE<Self, This>>,)

This is usually a tuple of Result<*mut _,E: IsFieldErr>s.

impl<This: ?Sized, S> RevIntoFieldImpl<This> for VariantName<TStr<S>> where
    This: IsVariant<TStr<S>>,
    S: 'static, 
[src]

impl<This, T> RevIntoMultiFieldImpl<This> for VariantName<T> where
    Self: RevIntoFieldImpl<This>,
    RGFT<Self, This>: Sized,
    Result<RGFT<Self, This>, RGFE<Self, This>>: NormalizeFields
[src]

type UnnormIntoFields = (Result<RGFT<Self, This>, RGFE<Self, This>>,)

This is usually a tuple of Result<_, E: IsFieldErr>s.

Auto Trait Implementations

impl<V> RefUnwindSafe for VariantName<V> where
    V: RefUnwindSafe

impl<V> Send for VariantName<V> where
    V: Send

impl<V> Sync for VariantName<V> where
    V: Sync

impl<V> Unpin for VariantName<V> where
    V: Unpin

impl<V> UnwindSafe for VariantName<V> where
    V: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<This, T> Array0<T> for This where
    This: ?Sized
[src]

impl<This, V, T> Array0Variant<T, V> for This where
    This: ?Sized
[src]

impl<This, T> ArrayMove0<T> for This where
    This: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<This, T> IntoStructural<T> for This where
    T: FromStructural<This>, 
[src]

impl<'a, Path, This> OptRevGetField<'a, This> for Path where
    Path: RevGetFieldImpl<'a, This, Err = FailedAccess>, 
[src]

impl<'a, Path, This> OptRevGetFieldMut<'a, This> for Path where
    Path: RevGetFieldMutImpl<'a, This, Err = FailedAccess>, 
[src]

impl<Path, This> OptRevIntoField<This> for Path where
    Path: RevIntoFieldImpl<This, Err = FailedAccess>, 
[src]

impl<'a, Path, This> OptRevIntoFieldMut<'a, This> for Path where
    Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>, 
[src]

impl<'a, Path, This> OptRevIntoFieldRef<'a, This> for Path where
    Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>, 
[src]

impl<'a, This, Path> RevGetMultiField<'a, This> for Path where
    Path: RevGetMultiFieldImpl<'a, This>,
    This: 'a + ?Sized
[src]

type Fields = <<Path as RevGetMultiFieldImpl<'a, This>>::UnnormFields as NormalizeFields>::Output

This is usually a tuple of Option<&_>s and &_s.

impl<'a, This, Path> RevGetMultiFieldMut<'a, This> for Path where
    Path: RevGetMultiFieldMutImpl<'a, This>,
    This: 'a + ?Sized
[src]

type FieldsMut = <<Path as RevGetMultiFieldMutImpl<'a, This>>::UnnormFieldsMut as NormalizeFields>::Output

This is usually a tuple of Option<&mut _>s and &mut _s.

type FieldsRawMut = <<Path as RevGetMultiFieldMutImpl<'a, This>>::UnnormFieldsRawMut as NormalizeFields>::Output

This is usually a tuple of Option<*mut _>s and *mut _s.

impl<This, Path> RevIntoMultiField<This> for Path where
    Path: RevIntoMultiFieldImpl<This>, 
[src]

type IntoFields = <<Path as RevIntoMultiFieldImpl<This>>::UnnormIntoFields as NormalizeFields>::Output

This is usually a tuple of Option<T>s and Ts.

impl<T> SelfOps for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The error type returned when the conversion fails.

impl<This, T> TryIntoStructural<T> for This where
    T: TryFromStructural<This>, 
[src]

type Error = <T as TryFromStructural<This>>::Error

The error parameter of TryFromError, returned from try_into_structural on conversion error. Read more

impl<T> TypeIdentity for T where
    T: ?Sized
[src]

type Type = T

The same type as Self. Read more