rustc_data_structures::undo_log

Trait UndoLogs

Source
pub trait UndoLogs<T> {
    // Required methods
    fn num_open_snapshots(&self) -> usize;
    fn push(&mut self, undo: T);
    fn clear(&mut self);

    // Provided methods
    fn in_snapshot(&self) -> bool { ... }
    fn extend<I>(&mut self, undos: I)
       where Self: Sized,
             I: IntoIterator<Item = T> { ... }
}
Expand description

A trait which allows undo actions (T) to be pushed which can be used to rollback actions at a later time if needed.

The undo actions themselves are opaque to UndoLogs, only specified Rollback implementations need to know what an action is and how to reverse it.

Required Methods§

Source

fn num_open_snapshots(&self) -> usize

How many open snapshots this undo log currently has

Source

fn push(&mut self, undo: T)

Pushes a new “undo item” onto the undo log. This method is invoked when some action is taken (e.g., a variable is unified). It records the info needed to reverse that action should an enclosing snapshot be rolled back.

Source

fn clear(&mut self)

Removes all items from the undo log.

Provided Methods§

Source

fn in_snapshot(&self) -> bool

True if a snapshot has started, false otherwise

Source

fn extend<I>(&mut self, undos: I)
where Self: Sized, I: IntoIterator<Item = T>,

Extends the undo log with many undos.

Implementations on Foreign Types§

Source§

impl<'a, T, U> UndoLogs<T> for &'a mut U
where U: UndoLogs<T>,

Source§

fn in_snapshot(&self) -> bool

Source§

fn num_open_snapshots(&self) -> usize

Source§

fn push(&mut self, undo: T)

Source§

fn clear(&mut self)

Source§

fn extend<I>(&mut self, undos: I)
where I: IntoIterator<Item = T>,

Implementors§

Source§

impl<T> UndoLogs<T> for NoUndo

Source§

impl<T> UndoLogs<T> for VecLog<T>