Trait utility_programming::Modifier [] [src]

pub trait Modifier<T> {
    type Change;
    fn modify(&mut self, obj: &mut T) -> Self::Change;
fn undo(&mut self, change: &Self::Change, obj: &mut T);
fn redo(&mut self, change: &Self::Change, obj: &mut T); fn undo_meaning(&mut self, _change: &Self::Change) { ... }
fn redo_meaning(&mut self, _change: &Self::Change) { ... } }

Modifies objects in a way that can be reversed.

Change in meaning of modifier

When there are multiple modifiers in the same context, such as a list of modifiers, then one modification might change the meaning of another.

For example, when an item is insert into a list:

  • [0, 3], inserting at 1 changes to [0, 4] (range includes index)
  • [2, 4], inserting at 0 changes to [3, 5] (range is after index)
  • [0, 3], inserting at 3 changes to [0, 3] (the same)

Meaning of a modifier is information that refers to information in the object. When the object changes, the consistency of the reference might require updating the modifier.

This is what the methods undo_meaning and redo_meaning do. They preserve meaning even though the change originated from another modifier.

Associated Types

The change applied to an object.

Required Methods

Modify an object and return the change.

This might be indeterministic. Use redo_meaning for applying change in meaning of modifier.

Undo change made to an object.

Required to be deterministic.

Redo change made to an object.

Required to be deterministic.

Provided Methods

Undo meaning change in the modifier introduced by a change.

This is called after undoing change by any modifier used in same context.

Redo meaning change in the modifier.

This is called after modification by any modifier used in same context.

Implementations on Foreign Types

impl<T, U: Modifier<T>> Modifier<T> for Vec<U>
[src]

[src]

[src]

[src]

[src]

[src]

Implementors