undoredo 0.8.21

Delta-based undo-redo decorator for collections such as HashMap, BTreeMap, StableVec, thunderdome::Arena, rstar::RTree. No need to implement commands.
Documentation
// SPDX-FileCopyrightText: 2025 undoredo contributors
//
// SPDX-License-Identifier: MIT OR Apache-2.0

use std::collections::{BTreeMap, BTreeSet};

use undoredo::{Recorder, UndoRedo};

fn main() {
    let mut recorder: Recorder<BTreeSet<char>, BTreeMap<char, ()>> = Recorder::new(BTreeSet::new());
    let mut undoredo: UndoRedo<BTreeMap<char, ()>> = UndoRedo::new();

    recorder.insert('A', ());
    undoredo.commit(recorder.flush_delta());

    recorder.insert('B', ());
    // Inserting to a set is idempotent: repeating the same insert does nothing.
    // It is, however, a logic error if the recorded collection is a multiset,
    // e.g. `rstar::RTree`.
    recorder.insert('B', ());
    undoredo.commit(recorder.flush_delta());

    recorder.insert('C', ());
    undoredo.commit(recorder.flush_delta());

    assert_eq!(*recorder.collection(), BTreeSet::from(['A', 'B', 'C']));

    undoredo.undo(&mut recorder);
    assert_eq!(*recorder.collection(), BTreeSet::from(['A', 'B']));

    undoredo.undo(&mut recorder);
    assert_eq!(*recorder.collection(), BTreeSet::from(['A']));

    undoredo.redo(&mut recorder);
    assert_eq!(*recorder.collection(), BTreeSet::from(['A', 'B']));

    undoredo.redo(&mut recorder);
    assert_eq!(*recorder.collection(), BTreeSet::from(['A', 'B', 'C']));
}

#[test]
fn test() {
    main();
}