@@ -10,35 +10,31 @@ use super::{VarValue, UnifyKey, UnifyValue};
10
10
#[ allow( type_alias_bounds) ]
11
11
type Key < S : UnificationStore > = <S as UnificationStore >:: Key ;
12
12
13
- pub trait Measurable {
14
- fn len ( & self ) -> usize ;
15
- }
16
-
17
13
/// Largely internal trait implemented by the unification table
18
14
/// backing store types. The most common such type is `InPlace`,
19
15
/// which indicates a standard, mutable unification table.
20
16
pub trait UnificationStore :
21
- ops:: Index < usize , Output = VarValue < Key < Self > > > + Measurable + Clone + Default
17
+ ops:: Index < usize , Output = VarValue < Key < Self > > > + Clone + Default
22
18
{
23
19
type Key : UnifyKey < Value = Self :: Value > ;
24
20
type Value : UnifyValue ;
25
- type Snapshot : Measurable ;
21
+ type Snapshot ;
26
22
27
23
fn start_snapshot ( & mut self ) -> Self :: Snapshot ;
28
24
29
25
fn rollback_to ( & mut self , snapshot : Self :: Snapshot ) ;
30
26
31
27
fn commit ( & mut self , snapshot : Self :: Snapshot ) ;
32
28
33
- fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > {
34
- snapshot. len ( ) ..self . len ( )
35
- }
29
+ fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > ;
36
30
37
31
fn reset_unifications (
38
32
& mut self ,
39
33
value : impl FnMut ( u32 ) -> VarValue < Self :: Key > ,
40
34
) ;
41
35
36
+ fn len ( & self ) -> usize ;
37
+
42
38
fn push ( & mut self , value : VarValue < Self :: Key > ) ;
43
39
44
40
fn reserve ( & mut self , num_new_values : usize ) ;
@@ -65,20 +61,6 @@ impl<K: UnifyKey> Default for InPlace<K> {
65
61
}
66
62
}
67
63
68
- impl Measurable for sv:: Snapshot {
69
- #[ inline]
70
- fn len ( & self ) -> usize {
71
- self . length
72
- }
73
- }
74
-
75
- impl < K : UnifyKey > Measurable for InPlace < K > {
76
- #[ inline]
77
- fn len ( & self ) -> usize {
78
- self . values . len ( )
79
- }
80
- }
81
-
82
64
impl < K : UnifyKey > UnificationStore for InPlace < K > {
83
65
type Key = K ;
84
66
type Value = K :: Value ;
@@ -99,6 +81,11 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
99
81
self . values . commit ( snapshot) ;
100
82
}
101
83
84
+ #[ inline]
85
+ fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > {
86
+ snapshot. value_count ..self . len ( )
87
+ }
88
+
102
89
#[ inline]
103
90
fn reset_unifications (
104
91
& mut self ,
@@ -107,6 +94,10 @@ impl<K: UnifyKey> UnificationStore for InPlace<K> {
107
94
self . values . set_all ( |i| value ( i as u32 ) ) ;
108
95
}
109
96
97
+ fn len ( & self ) -> usize {
98
+ self . values . len ( )
99
+ }
100
+
110
101
#[ inline]
111
102
fn push ( & mut self , value : VarValue < Self :: Key > ) {
112
103
self . values . push ( value) ;
@@ -158,14 +149,6 @@ impl<K: UnifyKey> Default for Persistent<K> {
158
149
}
159
150
}
160
151
161
- #[ cfg( feature = "persistent" ) ]
162
- impl < K : UnifyKey > Measurable for Persistent < K > {
163
- #[ inline]
164
- fn len ( & self ) -> usize {
165
- self . values . len ( )
166
- }
167
- }
168
-
169
152
#[ cfg( feature = "persistent" ) ]
170
153
impl < K : UnifyKey > UnificationStore for Persistent < K > {
171
154
type Key = K ;
@@ -183,7 +166,11 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
183
166
}
184
167
185
168
#[ inline]
186
- fn commit ( & mut self , _snapshot : Self :: Snapshot ) {
169
+ fn commit ( & mut self , _snapshot : Self :: Snapshot ) { }
170
+
171
+ #[ inline]
172
+ fn values_since_snapshot ( & self , snapshot : & Self :: Snapshot ) -> Range < usize > {
173
+ snapshot. len ( ) ..self . len ( )
187
174
}
188
175
189
176
#[ inline]
@@ -199,6 +186,10 @@ impl<K: UnifyKey> UnificationStore for Persistent<K> {
199
186
}
200
187
}
201
188
189
+ fn len ( & self ) -> usize {
190
+ self . values . len ( )
191
+ }
192
+
202
193
#[ inline]
203
194
fn push ( & mut self , value : VarValue < Self :: Key > ) {
204
195
self . values . push ( value) ;
0 commit comments