Skip to content

Commit 4b08d1c

Browse files
author
Markus Westerlind
committed
Allow Rollback on the wrapper storage types
1 parent bd84def commit 4b08d1c

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/snapshot_vec.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ pub enum UndoLog<D: SnapshotVecDelegate> {
4040
Other(D::Undo),
4141
}
4242

43+
impl<D: SnapshotVecDelegate> Rollback<UndoLog<D>> for SnapshotVecStorage<D> {
44+
fn reverse(&mut self, undo: UndoLog<D>) {
45+
self.values.reverse(undo)
46+
}
47+
}
4348
impl<D: SnapshotVecDelegate> Rollback<UndoLog<D>> for Vec<D::Value> {
4449
fn reverse(&mut self, undo: UndoLog<D>) {
4550
match undo {

src/unify/backing_vec.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use snapshot_vec as sv;
44
use std::marker::PhantomData;
55
use std::ops::{self, Range};
66

7-
use undo_log::{Snapshots, UndoLogs, VecLog};
7+
use undo_log::{Rollback, Snapshots, UndoLogs, VecLog};
88

99
use super::{UnifyKey, UnifyValue, VarValue};
1010

@@ -156,6 +156,12 @@ impl<K: UnifyKey> sv::SnapshotVecDelegate for Delegate<K> {
156156
fn reverse(_: &mut Vec<VarValue<K>>, _: ()) {}
157157
}
158158

159+
impl<K: UnifyKey> Rollback<sv::UndoLog<Delegate<K>>> for super::UnificationTableStorage<K> {
160+
fn reverse(&mut self, undo: sv::UndoLog<Delegate<K>>) {
161+
self.values.values.reverse(undo);
162+
}
163+
}
164+
159165
#[cfg(feature = "persistent")]
160166
#[derive(Clone, Debug)]
161167
pub struct Persistent<K: UnifyKey> {

0 commit comments

Comments
 (0)