Skip to main content

RevIntoField

Trait RevIntoField 

Source
pub trait RevIntoField<This>: RevIntoFieldImpl<This, Err = InfallibleAccess> { }
Expand description

A trait alias for an infallible RevIntoFieldImpl, generally used to access fields in structs(not in a nested enum inside the struct).

This is the type we are accessing,and Self is a field path.

§Example

This example shows how to access a nested struct field by value.

use structural::field::RevIntoField;
use structural::for_examples::StructBar;
use structural::{StructuralExt,FP,fp};

use std::cmp::Ordering;

let struct_=StructBar{
    bar: StructBar{
        bar: StructBar{
            bar: Ordering::Greater
        },
    },
};

assert_eq!( get_nested(struct_), Ordering::Greater );

fn get_nested<T>(this:T)->Ordering
where
    FP!(bar.bar.bar): RevIntoField<T,Ty=Ordering>
{
    this.into_field(fp!(bar.bar.bar))
}

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<Path, This> RevIntoField<This> for Path
where Path: RevIntoFieldImpl<This, Err = InfallibleAccess>,