@@ -4,7 +4,7 @@ use snapshot_vec as sv;
4
4
use std:: marker:: PhantomData ;
5
5
use std:: ops:: { self , Range } ;
6
6
7
- use undo_log:: { Rollback , Snapshots , VecLog } ;
7
+ use undo_log:: { Rollback , Snapshots , UndoLogs , VecLog } ;
8
8
9
9
use super :: { UnifyKey , UnifyValue , VarValue } ;
10
10
@@ -26,9 +26,7 @@ pub trait UnificationStoreBase: ops::Index<usize, Output = VarValue<Key<Self>>>
26
26
}
27
27
}
28
28
29
- pub trait UnificationStore : UnificationStoreBase {
30
- type Snapshot ;
31
-
29
+ pub trait UnificationStoreMut : UnificationStoreBase {
32
30
fn reset_unifications ( & mut self , value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ) ;
33
31
34
32
fn push ( & mut self , value : VarValue < Self :: Key > ) ;
@@ -38,6 +36,10 @@ pub trait UnificationStore: UnificationStoreBase {
38
36
fn update < F > ( & mut self , index : usize , op : F )
39
37
where
40
38
F : FnOnce ( & mut VarValue < Self :: Key > ) ;
39
+ }
40
+
41
+ pub trait UnificationStore : UnificationStoreMut {
42
+ type Snapshot ;
41
43
42
44
fn start_snapshot ( & mut self ) -> Self :: Snapshot ;
43
45
@@ -81,14 +83,12 @@ where
81
83
}
82
84
}
83
85
84
- impl < K , V , L > UnificationStore for InPlace < K , V , L >
86
+ impl < K , V , L > UnificationStoreMut for InPlace < K , V , L >
85
87
where
86
88
K : UnifyKey ,
87
89
V : sv:: VecLike < Delegate < K > > ,
88
- L : Snapshots < sv:: UndoLog < Delegate < K > > > ,
90
+ L : UndoLogs < sv:: UndoLog < Delegate < K > > > ,
89
91
{
90
- type Snapshot = sv:: Snapshot < L :: Snapshot > ;
91
-
92
92
#[ inline]
93
93
fn reset_unifications ( & mut self , mut value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ) {
94
94
self . values . set_all ( |i| value ( i as u32 ) ) ;
@@ -111,6 +111,15 @@ where
111
111
{
112
112
self . values . update ( index, op)
113
113
}
114
+ }
115
+
116
+ impl < K , V , L > UnificationStore for InPlace < K , V , L >
117
+ where
118
+ K : UnifyKey ,
119
+ V : sv:: VecLike < Delegate < K > > ,
120
+ L : Snapshots < sv:: UndoLog < Delegate < K > > > ,
121
+ {
122
+ type Snapshot = sv:: Snapshot < L :: Snapshot > ;
114
123
115
124
#[ inline]
116
125
fn start_snapshot ( & mut self ) -> Self :: Snapshot {
@@ -188,27 +197,7 @@ impl<K: UnifyKey> UnificationStoreBase for Persistent<K> {
188
197
}
189
198
190
199
#[ cfg( feature = "persistent" ) ]
191
- impl < K : UnifyKey > UnificationStore for Persistent < K > {
192
- type Snapshot = Self ;
193
-
194
- #[ inline]
195
- fn start_snapshot ( & mut self ) -> Self :: Snapshot {
196
- self . clone ( )
197
- }
198
-
199
- #[ inline]
200
- fn rollback_to ( & mut self , snapshot : Self :: Snapshot ) {
201
- * self = snapshot;
202
- }
203
-
204
- #[ inline]
205
- fn commit ( & mut self , _snapshot : Self :: Snapshot ) { }
206
-
207
- #[ inline]
208
- fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > {
209
- snapshot. len ( ) ..self . len ( )
210
- }
211
-
200
+ impl < K : UnifyKey > UnificationStoreMut for Persistent < K > {
212
201
#[ inline]
213
202
fn reset_unifications ( & mut self , mut value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ) {
214
203
// Without extending dogged, there isn't obviously a more
@@ -239,6 +228,29 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
239
228
}
240
229
}
241
230
231
+ #[ cfg( feature = "persistent" ) ]
232
+ impl < K : UnifyKey > UnificationStore for Persistent < K > {
233
+ type Snapshot = Self ;
234
+
235
+ #[ inline]
236
+ fn start_snapshot ( & mut self ) -> Self :: Snapshot {
237
+ self . clone ( )
238
+ }
239
+
240
+ #[ inline]
241
+ fn rollback_to ( & mut self , snapshot : Self :: Snapshot ) {
242
+ * self = snapshot;
243
+ }
244
+
245
+ #[ inline]
246
+ fn commit ( & mut self , _snapshot : Self :: Snapshot ) { }
247
+
248
+ #[ inline]
249
+ fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > {
250
+ snapshot. len ( ) ..self . len ( )
251
+ }
252
+ }
253
+
242
254
#[ cfg( feature = "persistent" ) ]
243
255
impl < K > ops:: Index < usize > for Persistent < K >
244
256
where
0 commit comments