[−][src]Trait structural::field::rev_get_field::OptRevIntoField
A trait alias for a fallible RevIntoFieldImpl
,
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 value.
use structural::field::OptRevIntoField; use structural::for_examples::{StructFoo,WithBoom}; use structural::{StructuralExt,FP,fp}; let nope=StructFoo{ foo: WithBoom::Nope }; let boom=StructFoo{ foo: WithBoom::Boom{ a: "hello", b: &[3,5,8,13] } }; assert_eq!( get_nested(nope), None ); assert_eq!( get_nested(boom), Some(&[3,5,8,13][..]) ); fn get_nested<T>(this:T)->Option<&'static [u16]> where FP!(foo::Boom.b): OptRevIntoField<T,Ty=&'static [u16]> { this.into_field(fp!(foo::Boom.b)) }
Implementors
impl<Path, This> OptRevIntoField<This> for Path where
Path: RevIntoFieldImpl<This, Err = FailedAccess>,
[src]
Path: RevIntoFieldImpl<This, Err = FailedAccess>,