# Undoredo - crate for Undo/Redo using deltas, snapshots, or commands

**URL:** <https://users.rust-lang.org/t/undoredo-crate-for-undo-redo-using-deltas-snapshots-or-commands/140030>\
**Category:** announcements\
**Created:** [May 10, 2026, 3:47pm UTC](https://users.rust-lang.org/t/undoredo-crate-for-undo-redo-using-deltas-snapshots-or-commands/140030 "2026-05-10T15:47:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikwielgus](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/mikwielgus/32/53549_2.png) [@mikwielgus](https://users.rust-lang.org/u/mikwielgus)\
**Post date:** [May 10, 2026, 3:47pm UTC](https://users.rust-lang.org/t/undoredo-crate-for-undo-redo-using-deltas-snapshots-or-commands/140030/1 "2026-05-10T15:47:30Z")

</div>

Hello! I would like to share with you a library that I created for my own needs.

`undoredo` is a Rust crate for implementing Undo/Redo pattern using deltas, snapshots, or commands on arbitrary data structures.

The library has derive macros for custom data structures, and there is a large number of convenience implementations for standard library and third-party types, such as `HashMap`, `HashSet`, `BTreeMap`, `BTreeSet`, `Vec`, `StableVec`, `thunderdome::Arena`, `rstar::RTree`, `rstared::RTreed`. There is also plenty of documentation.

Links: [repository](https://github.com/mikwielgus/undoredo), [crate](https://crates.io/crates/undoredo), [docs](https://docs.rs/undoredo/latest/undoredo/)

Example:

```rust
use undoredo::{Delta, Recorder, UndoRedo};

#[derive(Delta)]
pub struct Entities {
    positions: Recorder<Vec<[f64; 2]>>,
    velocities: Recorder<Vec<[f64; 2]>>,
    healths: Recorder<Vec<i64>>,
}

fn main() {
    let mut entities = Entities {
        positions: Recorder::new(Vec::new()),
        velocities: Recorder::new(Vec::new()),
        healths: Recorder::new(Vec::new()),
    };
    let mut undoredo: UndoRedo<EntitiesDelta> = UndoRedo::new();

    entities.positions.push([0.0, 0.0]);
    entities.velocities.push([1.0, 0.0]);
    entities.healths.push(100);

    undoredo.commit(&mut entities);

    undoredo.undo(&mut entities);
    undoredo.redo(&mut entities);
}

```

Here's a demo animation showing Undo/Redo action over dynamically added and subtracted polygons with R-tree spatial indexing. Neither commands nor snapshots are stored, but all edits in history are made of sparse deltas of the polygon container and the associated R-tree:

![polygonsetdemo](https://us1.discourse-cdn.com/flex019/uploads/rust_lang/original/3X/9/f/9f209d2c7c114e8fb69f59634289503ed5ac6831.gif)

---

<div class="post-metadata">

**Author:** ![nerjs](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/nerjs/32/52341_2.png) [@nerjs](https://users.rust-lang.org/u/nerjs)\
**Post date:** [May 10, 2026, 5:27pm UTC](https://users.rust-lang.org/t/undoredo-crate-for-undo-redo-using-deltas-snapshots-or-commands/140030/2 "2026-05-10T17:27:02Z")

</div>

That looks interesting. I'll have to give it a try sometime.

---

<div class="post-metadata">

**Author:** ![system](https://sea1.discourse-cdn.com/flex019/user_avatar/users.rust-lang.org/system/32/51372_2.png) [@system](https://users.rust-lang.org/u/system)\
**Post date:** [August 8, 2026, 5:27pm UTC](https://users.rust-lang.org/t/undoredo-crate-for-undo-redo-using-deltas-snapshots-or-commands/140030/3 "2026-08-08T17:27:31Z")

</div>

Closed on August 8, 2026, 5:27pm UTC

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.
