Skip to main content

Foldable

Trait Foldable 

Source
pub trait Foldable<A: AstTypes, B: AstTypes>: Sized {
    type Out;

    // Required methods
    fn fold_in<F: Fold<A, B> + ?Sized>(
        self,
        folder: &mut F,
    ) -> Result<Self::Out, F::Error>;
    fn children<F: Fold<A, B> + ?Sized>(
        self,
        folder: &mut F,
    ) -> Result<Self::Out, F::Error>;
}

Required Associated Types§

Source

type Out

The return type of the associated Fold function

Required Methods§

Source

fn fold_in<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Calls Self’s appropriate Folder function(s)

Source

fn children<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Destructures self, calling Foldable::fold_in on all foldable members, and rebuilds a Self out of the results.

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.

Implementations on Foreign Types§

Source§

impl<T, A, B> Foldable<A, B> for Box<T>
where T: Foldable<A, B>, A: AstTypes, B: AstTypes,

Source§

type Out = Box<<T as Foldable<A, B>>::Out>

Source§

fn fold_in<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Source§

fn children<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Source§

impl<T: Foldable<A, B>, A: AstTypes, B: AstTypes> Foldable<A, B> for Option<T>

Source§

type Out = Option<<T as Foldable<A, B>>::Out>

Source§

fn fold_in<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Source§

fn children<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Source§

impl<T: Foldable<A, B>, A: AstTypes, B: AstTypes> Foldable<A, B> for Vec<T>

Source§

type Out = Vec<<T as Foldable<A, B>>::Out>

Source§

fn fold_in<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Source§

fn children<F: Fold<A, B> + ?Sized>( self, folder: &mut F, ) -> Result<Self::Out, F::Error>

Implementors§

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Expr<A>

Source§

type Out = Expr<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Pat<A>

Source§

type Out = Pat<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Use<A>

Source§

type Out = Use<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for At<Expr<A>, A>

Source§

type Out = At<Expr<B>, B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Bind<A>

Source§

type Out = Bind<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Make<A>

Source§

type Out = Make<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for MakeArm<A>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for Match<A>

Source§

type Out = Match<B>

Source§

impl<A: AstTypes, B: AstTypes> Foldable<A, B> for MatchArm<A>