Visitor

Trait Visitor 

Source
pub trait Visitor<I: Layout> {
    // Provided methods
    fn visit_type(&mut self, ty: &Type<I>) { ... }
    fn visit_annotations(&mut self, annotations: &[Annotation]) { ... }
    fn visit_builtin_type(&mut self, builtin_type: BuiltinType, ty: &Type<I>) { ... }
    fn visit_record(&mut self, record: &Record<I>, ty: &Type<I>) { ... }
    fn visit_record_field(
        &mut self,
        field: &RecordField<I>,
        record: &Record<I>,
        ty: &Type<I>,
    ) { ... }
    fn visit_typedef(&mut self, dst: &Type<I>, ty: &Type<I>) { ... }
    fn visit_array(&mut self, array: &Array<I>, ty: &Type<I>) { ... }
    fn visit_opaque_type(&mut self, layout: I::OpaqueLayout, ty: &Type<I>) { ... }
    fn visit_enum(&mut self, variants: &[i128], ty: &Type<I>) { ... }
}
Expand description

This trait represents a visitor that walks through a Type.

Each method’s default implementation is accessible through the function of the same name in the visitor module.

§Example

struct Impl;

impl<I: Layout> Visitor<I> for Impl {
    fn visit_enum(&mut self, variants: &[i128], ty: &Type<I>) {
        println!("Variants: {:?}", variants);
        visit_enum(self, variants, ty)
    }
}

Provided Methods§

Source

fn visit_type(&mut self, ty: &Type<I>)

Called for types.

Source

fn visit_annotations(&mut self, annotations: &[Annotation])

Called for the annotations on a type or field.

Source

fn visit_builtin_type(&mut self, builtin_type: BuiltinType, ty: &Type<I>)

Called for builtin types.

Source

fn visit_record(&mut self, record: &Record<I>, ty: &Type<I>)

Called for records.

Source

fn visit_record_field( &mut self, field: &RecordField<I>, record: &Record<I>, ty: &Type<I>, )

Called for record fields.

Source

fn visit_typedef(&mut self, dst: &Type<I>, ty: &Type<I>)

Called for typedefs.

Source

fn visit_array(&mut self, array: &Array<I>, ty: &Type<I>)

Called for arrays.

Source

fn visit_opaque_type(&mut self, layout: I::OpaqueLayout, ty: &Type<I>)

Called for opaque types.

Source

fn visit_enum(&mut self, variants: &[i128], ty: &Type<I>)

Called for enums.

Implementors§