[−][src]Struct structural::VariantField
This allows accessing the F
field inside the V
enum variant.
This is the type that fp!(::Foo.bar)
constructs.
Both the V
and F
type parameters are TStr.
Construction
You can construct this using (not an exhaustive list):
-
The
fp
macro, withfp!(::Foo.bar)
-
The
VariantField{variant,field}
struct literal -
The
new
constructor. -
The
NEW
associated constant,if bothV
andF
implementcore_extensions::ConstDefault
(reexported instructural::reexports::ConstDefault
).
Example
use structural::{StructuralExt, fp, ts}; use structural::for_examples::Variants; use structural::path::VariantField; let mut foo=Variants::Foo(3,5); assert_eq!( foo.field_(fp!(::Foo.0)), Some(&3) ); assert_eq!( foo.field_(fp!(::Foo.1)), Some(&5) ); assert_eq!( foo.field_(fp!(::Boom.a)), None ); assert_eq!( foo.field_(fp!(::Boom.b)), None ); assert_eq!( foo.field_(VariantField::new(ts!(Foo), ts!(0))), Some(&3) ); assert_eq!( foo.field_(VariantField::new(ts!(Foo), ts!(1))), Some(&5) ); assert_eq!( foo.field_(VariantField::new(ts!(Boom), ts!(a))), None ); assert_eq!( foo.field_(VariantField::new(ts!(Boom), ts!(b))), None ); assert_eq!( foo.field_mut(fp!(::Foo.0)), Some(&mut 3) ); assert_eq!( foo.field_mut(fp!(::Foo.1)), Some(&mut 5) ); assert_eq!( foo.field_mut(fp!(::Boom.a)), None ); assert_eq!( foo.field_mut(fp!(::Boom.b)), None ); assert_eq!( foo.field_mut(VariantField::new(ts!(Foo), ts!(0))), Some(&mut 3) ); assert_eq!( foo.field_mut(VariantField::new(ts!(Foo), ts!(1))), Some(&mut 5) ); assert_eq!( foo.field_mut(VariantField::new(ts!(Boom), ts!(a))), None ); assert_eq!( foo.field_mut(VariantField::new(ts!(Boom), ts!(b))), None );
Fields
variant: V
The variant this accesses.
field: F
The field this accesses inside the variant.
Implementations
impl<V, F> VariantField<V, F> where
V: ConstDefault,
F: ConstDefault,
[src]
V: ConstDefault,
F: ConstDefault,
impl<V, F> VariantField<V, F>
[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, F> VariantField<V, F>
[src]
pub const fn new(variant: V, field: F) -> Self
[src]
Constructs a VariantField from the name of the variant,and field.
Both name
and field
is expected to be a ::structural::path::TStr.
Trait Implementations
impl<V: Clone, F: Clone> Clone for VariantField<V, F>
[src]
fn clone(&self) -> VariantField<V, F>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<V, F> ConstDefault for VariantField<V, F> where
V: ConstDefault,
F: ConstDefault,
[src]
V: ConstDefault,
F: ConstDefault,
impl<V: Copy, F: Copy> Copy for VariantField<V, F>
[src]
impl<T, U> Debug for VariantField<T, U>
[src]
impl<V, F> Eq for VariantField<V, F>
[src]
impl<T, E> FieldType<VariantField<TStr<__TS<(__E, __r, __r)>>, TStr<__TS<(__0,)>>>> for Result<T, E>
[src]
type Ty = E
The type of the FieldPath
field.
impl<T, E> FieldType<VariantField<TStr<__TS<(__O, __k)>>, TStr<__TS<(__0,)>>>> for Result<T, E>
[src]
type Ty = T
The type of the FieldPath
field.
impl<T> FieldType<VariantField<TStr<__TS<(__S, __o, __m, __e)>>, TStr<__TS<(__0,)>>>> for Option<T>
[src]
type Ty = T
The type of the FieldPath
field.
impl<V, F> IsMultiFieldPath for VariantField<V, F>
[src]
type PathUniqueness = UniquePaths
Whether the paths in the set can contain duplicate paths. Read more
impl<V, F> IsSingleFieldPath for VariantField<V, F>
[src]
impl<V, F> Ord for VariantField<V, F>
[src]
fn cmp(&self, _other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<V, F> PartialEq<VariantField<V, F>> for VariantField<V, F>
[src]
impl<V, F> PartialOrd<VariantField<V, F>> for VariantField<V, F>
[src]
fn partial_cmp(&self, _other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl<This: ?Sized, _V, _F> RevFieldErr<This> for VariantField<_V, _F> where
This: FieldType<Self>,
[src]
This: FieldType<Self>,
type Err = FailedAccess
The error returned by rev_*
methods. Read more
impl<This: ?Sized, _V, _F> RevFieldType<This> for VariantField<_V, _F> where
This: FieldType<Self>,
[src]
This: FieldType<Self>,
type Ty = GetFieldType<This, Self>
The type of the field.
impl<'a, This: ?Sized, _V, _F> RevGetFieldImpl<'a, This> for VariantField<_V, _F> where
This: 'a + GetVariantField<_V, _F>,
This::Ty: 'a,
[src]
This: 'a + GetVariantField<_V, _F>,
This::Ty: 'a,
fn rev_get_field(self, this: &'a This) -> Result<&'a This::Ty, FailedAccess>
[src]
impl<'a, This: ?Sized, _V, _F> RevGetFieldMutImpl<'a, This> for VariantField<_V, _F> where
This: 'a + GetVariantFieldMut<_V, _F>,
This::Ty: 'a,
[src]
This: 'a + GetVariantFieldMut<_V, _F>,
This::Ty: 'a,
fn rev_get_field_mut(
self,
this: &'a mut This
) -> Result<&'a mut This::Ty, FailedAccess>
[src]
self,
this: &'a mut This
) -> Result<&'a mut This::Ty, FailedAccess>
unsafe fn rev_get_field_raw_mut(
self,
this: *mut This
) -> Result<*mut This::Ty, FailedAccess>
[src]
self,
this: *mut This
) -> Result<*mut This::Ty, FailedAccess>
impl<'a, This: ?Sized, V, F> RevGetMultiFieldImpl<'a, This> for VariantField<V, F> where
Self: RevGetFieldImpl<'a, This>,
This: 'a,
RGFT<Self, This>: 'a,
Result<&'a RGFT<Self, This>, RGFE<Self, This>>: 'a + NormalizeFields,
[src]
Self: RevGetFieldImpl<'a, This>,
This: 'a,
RGFT<Self, This>: 'a,
Result<&'a RGFT<Self, This>, RGFE<Self, This>>: 'a + NormalizeFields,
type UnnormFields = (Result<&'a RGFT<Self, This>, RGFE<Self, This>>,)
A collection of Results<&'a _,_>
s referencing fields.
fn rev_get_multi_field_impl(
self,
this: &'a This
) -> (Result<&'a RGFT<Self, This>, RGFE<Self, This>>,)
[src]
self,
this: &'a This
) -> (Result<&'a RGFT<Self, This>, RGFE<Self, This>>,)
impl<'a, This: ?Sized, V, F> RevGetMultiFieldMutImpl<'a, This> for VariantField<V, F> 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]
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,
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.
fn rev_get_multi_field_mut_impl(
self,
this: &'a mut This
) -> (Result<&'a mut RGFT<Self, This>, RGFE<Self, This>>,)
[src]
self,
this: &'a mut This
) -> (Result<&'a mut RGFT<Self, This>, RGFE<Self, This>>,)
unsafe fn rev_get_multi_field_raw_mut_impl(
self,
this: *mut This
) -> (Result<*mut RGFT<Self, This>, RGFE<Self, This>>,)
[src]
self,
this: *mut This
) -> (Result<*mut RGFT<Self, This>, RGFE<Self, This>>,)
impl<This: ?Sized, _V, _F> RevIntoFieldImpl<This> for VariantField<_V, _F> where
This: IntoVariantField<_V, _F>,
[src]
This: IntoVariantField<_V, _F>,
fn rev_into_field(self, this: This) -> Result<This::Ty, FailedAccess> where
This: Sized,
[src]
This: Sized,
impl<This, V, F> RevIntoMultiFieldImpl<This> for VariantField<V, F> where
Self: RevIntoFieldImpl<This>,
RGFT<Self, This>: Sized,
Result<RGFT<Self, This>, RGFE<Self, This>>: NormalizeFields,
[src]
Self: RevIntoFieldImpl<This>,
RGFT<Self, This>: Sized,
Result<RGFT<Self, This>, RGFE<Self, This>>: NormalizeFields,
type UnnormIntoFields = (Result<RGFT<Self, This>, RGFE<Self, This>>,)
This is usually a tuple of Result<_, E: IsFieldErr>
s.
fn rev_into_multi_field_impl(
self,
this: This
) -> (Result<RGFT<Self, This>, RGFE<Self, This>>,)
[src]
self,
this: This
) -> (Result<RGFT<Self, This>, RGFE<Self, This>>,)
impl<This: ?Sized, _V, _F> RevMoveOutFieldImpl<This> for VariantField<_V, _F> where
This: IntoVariantField<_V, _F>,
[src]
This: IntoVariantField<_V, _F>,
unsafe fn rev_move_out_field(
self,
this: &mut This,
moved: &mut MovedOutFields
) -> Result<This::Ty, FailedAccess> where
This::Ty: Sized,
[src]
self,
this: &mut This,
moved: &mut MovedOutFields
) -> Result<This::Ty, FailedAccess> where
This::Ty: Sized,
impl<V, F> ShallowFieldPath for VariantField<V, F>
[src]
Auto Trait Implementations
impl<V, F> RefUnwindSafe for VariantField<V, F> where
F: RefUnwindSafe,
V: RefUnwindSafe,
F: RefUnwindSafe,
V: RefUnwindSafe,
impl<V, F> Send for VariantField<V, F> where
F: Send,
V: Send,
F: Send,
V: Send,
impl<V, F> Sync for VariantField<V, F> where
F: Sync,
V: Sync,
F: Sync,
V: Sync,
impl<V, F> Unpin for VariantField<V, F> where
F: Unpin,
V: Unpin,
F: Unpin,
V: Unpin,
impl<V, F> UnwindSafe for VariantField<V, F> where
F: UnwindSafe,
V: UnwindSafe,
F: UnwindSafe,
V: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<This, T> Array0<T> for This where
This: ?Sized,
[src]
This: ?Sized,
impl<This, V, T> Array0Variant<T, V> for This where
This: ?Sized,
[src]
This: ?Sized,
impl<This, T> ArrayMove0<T> for This where
This: ?Sized,
[src]
This: ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<This, T> IntoStructural<T> for This where
T: FromStructural<This>,
[src]
T: FromStructural<This>,
fn into_structural(Self) -> T
[src]
impl<'a, Path, This> OptRevGetField<'a, This> for Path where
Path: RevGetFieldImpl<'a, This, Err = FailedAccess>,
[src]
Path: RevGetFieldImpl<'a, This, Err = FailedAccess>,
impl<'a, Path, This> OptRevGetFieldMut<'a, This> for Path where
Path: RevGetFieldMutImpl<'a, This, Err = FailedAccess>,
[src]
Path: RevGetFieldMutImpl<'a, This, Err = FailedAccess>,
impl<Path, This> OptRevIntoField<This> for Path where
Path: RevIntoFieldImpl<This, Err = FailedAccess>,
[src]
Path: RevIntoFieldImpl<This, Err = FailedAccess>,
impl<'a, Path, This> OptRevIntoFieldMut<'a, This> for Path where
Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>,
[src]
Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>,
impl<'a, Path, This> OptRevIntoFieldRef<'a, This> for Path where
Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>,
[src]
Path: OptRevIntoField<This> + OptRevGetFieldMut<'a, This>,
impl<'a, This, Path> RevGetMultiField<'a, This> for Path where
Path: RevGetMultiFieldImpl<'a, This>,
This: 'a + ?Sized,
[src]
Path: RevGetMultiFieldImpl<'a, This>,
This: 'a + ?Sized,
type Fields = <<Path as RevGetMultiFieldImpl<'a, This>>::UnnormFields as NormalizeFields>::Output
This is usually a tuple of Option<&_>
s and &_
s.
fn rev_get_multi_field(
Self,
&'a This
) -> <Path as RevGetMultiField<'a, This>>::Fields
[src]
Self,
&'a This
) -> <Path as RevGetMultiField<'a, This>>::Fields
impl<'a, This, Path> RevGetMultiFieldMut<'a, This> for Path where
Path: RevGetMultiFieldMutImpl<'a, This>,
This: 'a + ?Sized,
[src]
Path: RevGetMultiFieldMutImpl<'a, This>,
This: 'a + ?Sized,
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.
fn rev_get_multi_field_mut(
Self,
&'a mut This
) -> <Path as RevGetMultiFieldMut<'a, This>>::FieldsMut
[src]
Self,
&'a mut This
) -> <Path as RevGetMultiFieldMut<'a, This>>::FieldsMut
unsafe fn rev_get_multi_field_raw_mut(
Self,
*mut This
) -> <Path as RevGetMultiFieldMut<'a, This>>::FieldsRawMut
[src]
Self,
*mut This
) -> <Path as RevGetMultiFieldMut<'a, This>>::FieldsRawMut
impl<This, Path> RevIntoMultiField<This> for Path where
Path: RevIntoMultiFieldImpl<This>,
[src]
Path: RevIntoMultiFieldImpl<This>,
type IntoFields = <<Path as RevIntoMultiFieldImpl<This>>::UnnormIntoFields as NormalizeFields>::Output
This is usually a tuple of Option<T>
s and T
s.
fn rev_into_multi_field(
Self,
This
) -> <Path as RevIntoMultiField<This>>::IntoFields
[src]
Self,
This
) -> <Path as RevIntoMultiField<This>>::IntoFields
impl<T> SelfOps for T where
T: ?Sized,
[src]
T: ?Sized,
const T: PhantomData<fn() -> Self>
[src]
const T_D: PhantomData<Self>
[src]
fn assert_ty(self, _other: PhantomData<fn() -> Self>) -> Self
[src]
fn assert_ty_ref(&self, _other: PhantomData<fn() -> Self>) -> &Self
[src]
fn assert_ty_mut(&mut self, _other: PhantomData<fn() -> Self>) -> &mut Self
[src]
fn ty_(&self) -> PhantomData<fn() -> Self>
[src]
fn ty_d(&self) -> PhantomData<Self>
[src]
fn ty_inv(&self) -> PhantomData<fn(Self) -> Self>
[src]
fn ty_inv_ref(&self) -> PhantomData<Cell<&Self>>
[src]
fn eq_id(&self, other: &Self) -> bool
[src]
fn piped<F, U>(self, f: F) -> U where
F: FnOnce(Self) -> U,
[src]
F: FnOnce(Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> U where
F: FnOnce(&'a Self) -> U,
[src]
F: FnOnce(&'a Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> U where
F: FnOnce(&'a mut Self) -> U,
[src]
F: FnOnce(&'a mut Self) -> U,
fn mutated<F>(self, f: F) -> Self where
F: FnOnce(&mut Self),
[src]
F: FnOnce(&mut Self),
fn observe<F>(self, f: F) -> Self where
F: FnOnce(&Self),
[src]
F: FnOnce(&Self),
fn into_<T>(self, PhantomData<fn() -> T>) -> T where
Self: Into<T>,
[src]
Self: Into<T>,
fn as_ref_<T>(&self) -> &T where
Self: AsRef<T>,
T: ?Sized,
[src]
Self: AsRef<T>,
T: ?Sized,
fn as_mut_<T>(&mut self) -> &mut T where
Self: AsMut<T>,
T: ?Sized,
[src]
Self: AsMut<T>,
T: ?Sized,
fn drop_(self)
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The error type returned when the conversion fails.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<This, T> TryIntoStructural<T> for This where
T: TryFromStructural<This>,
[src]
T: TryFromStructural<This>,
type Error = <T as TryFromStructural<This>>::Error
The error parameter of TryFromError
, returned from try_into_structural
on conversion error. Read more
fn try_into_structural(
Self
) -> Result<T, TryFromError<This, <This as TryIntoStructural<T>>::Error>>
[src]
Self
) -> Result<T, TryFromError<This, <This as TryIntoStructural<T>>::Error>>
impl<T> TypeIdentity for T where
T: ?Sized,
[src]
T: ?Sized,
type Type = T
The same type as Self. Read more
fn into_type_val(self) -> Self::Type where
Self::Type: Sized,
[src]
Self::Type: Sized,
fn into_type_ref(&self) -> &Self::Type
[src]
fn into_type_mut(&mut self) -> &mut Self::Type
[src]
fn into_type_box(self: Box<Self>) -> Box<Self::Type>ⓘImportant traits for Box<R>
impl<R> Read for Box<R> where
R: Read + ?Sized, impl<W> Write for Box<W> where
W: Write + ?Sized, impl<F> Future for Box<F> where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I> Iterator for Box<I> where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Important traits for Box<R>
impl<R> Read for Box<R> where
R: Read + ?Sized, impl<W> Write for Box<W> where
W: Write + ?Sized, impl<F> Future for Box<F> where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I> Iterator for Box<I> where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
fn into_type_arc(this: Arc<Self>) -> Arc<Self::Type>
[src]
fn into_type_rc(this: Rc<Self>) -> Rc<Self::Type>
[src]
fn from_type_val(this: Self::Type) -> Self where
Self::Type: Sized,
[src]
Self::Type: Sized,
fn from_type_ref(this: &Self::Type) -> &Self
[src]
fn from_type_mut(this: &mut Self::Type) -> &mut Self
[src]
fn from_type_box(this: Box<Self::Type>) -> Box<Self>ⓘImportant traits for Box<R>
impl<R> Read for Box<R> where
R: Read + ?Sized, impl<W> Write for Box<W> where
W: Write + ?Sized, impl<F> Future for Box<F> where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I> Iterator for Box<I> where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;
[src]
Important traits for Box<R>
impl<R> Read for Box<R> where
R: Read + ?Sized, impl<W> Write for Box<W> where
W: Write + ?Sized, impl<F> Future for Box<F> where
F: Unpin + Future + ?Sized, type Output = <F as Future>::Output;impl<I> Iterator for Box<I> where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;