@@ -61,7 +61,7 @@ impl<D> fmt::Debug for SnapshotVec<D>
61
61
// Snapshots are tokens that should be created/consumed linearly.
62
62
pub struct Snapshot {
63
63
// Length of the undo log at the time the snapshot was taken.
64
- pub ( crate ) length : usize ,
64
+ undo_len : usize ,
65
65
}
66
66
67
67
pub trait SnapshotVecDelegate {
@@ -176,24 +176,27 @@ impl<D: SnapshotVecDelegate> SnapshotVec<D> {
176
176
let length = self . undo_log . len ( ) ;
177
177
self . num_open_snapshots += 1 ;
178
178
Snapshot { length : length }
179
+ Snapshot {
180
+ undo_len : self . undo_log . len ( ) ,
181
+ }
179
182
}
180
183
181
184
pub fn actions_since_snapshot ( & self , snapshot : & Snapshot ) -> & [ UndoLog < D > ] {
182
- & self . undo_log [ snapshot. length ..]
185
+ & self . undo_log [ snapshot. undo_len ..]
183
186
}
184
187
185
188
fn assert_open_snapshot ( & self , snapshot : & Snapshot ) {
186
189
// Failures here may indicate a failure to follow a stack discipline.
187
- assert ! ( self . undo_log. len( ) >= snapshot. length ) ;
190
+ assert ! ( self . undo_log. len( ) >= snapshot. undo_len ) ;
188
191
assert ! ( self . num_open_snapshots > 0 ) ;
189
192
}
190
193
191
194
pub fn rollback_to ( & mut self , snapshot : Snapshot ) {
192
- debug ! ( "rollback_to({})" , snapshot. length ) ;
195
+ debug ! ( "rollback_to({})" , snapshot. undo_len ) ;
193
196
194
197
self . assert_open_snapshot ( & snapshot) ;
195
198
196
- while self . undo_log . len ( ) > snapshot. length {
199
+ while self . undo_log . len ( ) > snapshot. undo_len {
197
200
match self . undo_log . pop ( ) . unwrap ( ) {
198
201
NewElem ( i) => {
199
202
self . values . pop ( ) ;
@@ -216,15 +219,15 @@ impl<D: SnapshotVecDelegate> SnapshotVec<D> {
216
219
/// Commits all changes since the last snapshot. Of course, they
217
220
/// can still be undone if there is a snapshot further out.
218
221
pub fn commit ( & mut self , snapshot : Snapshot ) {
219
- debug ! ( "commit({})" , snapshot. length ) ;
222
+ debug ! ( "commit({})" , snapshot. undo_len ) ;
220
223
221
224
self . assert_open_snapshot ( & snapshot) ;
222
225
223
226
if self . num_open_snapshots == 1 {
224
227
// The root snapshot. It's safe to clear the undo log because
225
228
// there's no snapshot further out that we might need to roll back
226
229
// to.
227
- assert ! ( snapshot. length == 0 ) ;
230
+ assert ! ( snapshot. undo_len == 0 ) ;
228
231
self . undo_log . clear ( ) ;
229
232
}
230
233
0 commit comments