[−][src]Trait structural::field::rev_get_field::OptRevGetField
A trait alias for a fallible RevGetFieldImpl
,
generally used to access fields inside enums.
This
is the type we are accessing,and Self
is a field path.
Example
This example shows how you can access an enum field by reference.
use structural::field::OptRevGetField; use structural::{StructuralExt,FP,fp}; let tup1=(3,5,(8,(Some(13),21))); let tup2=(3,5,(8,(None,21))); assert_eq!( get_nested(&tup1), Some(&13) ); assert_eq!( get_nested(&tup2), None ); fn get_nested<'a,T>(this:&'a T)->Option<&'a i32> where FP!(2.1.0?): OptRevGetField<'a,T,Ty=i32> { this.field_(fp!(2.1.0?)) }
Implementors
impl<'a, Path, This> OptRevGetField<'a, This> for Path where
Path: RevGetFieldImpl<'a, This, Err = FailedAccess>,
[src]
Path: RevGetFieldImpl<'a, This, Err = FailedAccess>,