Trait derive_visitor::VisitorMut

source ·
pub trait VisitorMut {
    // Required method
    fn visit(&mut self, item: &mut dyn Any, event: Event);
}
Expand description

An interface for visiting data structures and mutating them during the visit.

It works exactly the same as Visitor, but it takes a mutable reference to the visited element.

use derive_visitor::VisitorMut;

struct Chain {
    next: Option<Box<Chain>>
}

#[derive(VisitorMut)]
#[visitor(Chain(enter))]
struct ChainCutter;

impl ChainCutter {
    fn enter_chain(&mut self, item: &mut Chain) {
        item.next = None
    }
}

Required Methods§

source

fn visit(&mut self, item: &mut dyn Any, event: Event)

Implementors§