@@ -12,13 +12,13 @@ type Key<S> = <S as UnificationStore>::Key;
12
12
/// Largely internal trait implemented by the unification table
13
13
/// backing store types. The most common such type is `InPlace`,
14
14
/// which indicates a standard, mutable unification table.
15
- pub trait UnificationStore : ops:: Index < usize , Output = VarValue < Key < Self > > > + Clone {
15
+ pub trait UnificationStore :
16
+ ops:: Index < usize , Output = VarValue < Key < Self > > > + Clone + Default
17
+ {
16
18
type Key : UnifyKey < Value = Self :: Value > ;
17
19
type Value : UnifyValue ;
18
20
type Snapshot ;
19
21
20
- fn new ( ) -> Self ;
21
-
22
22
fn start_snapshot ( & mut self ) -> Self :: Snapshot ;
23
23
24
24
fn rollback_to ( & mut self , snapshot : Self :: Snapshot ) ;
@@ -51,16 +51,18 @@ pub struct InPlace<K: UnifyKey> {
51
51
values : sv:: SnapshotVec < Delegate < K > >
52
52
}
53
53
54
+ // HACK(eddyb) manual impl avoids `Default` bound on `K`.
55
+ impl < K : UnifyKey > Default for InPlace < K > {
56
+ fn default ( ) -> Self {
57
+ InPlace { values : sv:: SnapshotVec :: new ( ) }
58
+ }
59
+ }
60
+
54
61
impl < K : UnifyKey > UnificationStore for InPlace < K > {
55
62
type Key = K ;
56
63
type Value = K :: Value ;
57
64
type Snapshot = sv:: Snapshot ;
58
65
59
- #[ inline]
60
- fn new ( ) -> Self {
61
- InPlace { values : sv:: SnapshotVec :: new ( ) }
62
- }
63
-
64
66
#[ inline]
65
67
fn start_snapshot ( & mut self ) -> Self :: Snapshot {
66
68
self . values . start_snapshot ( )
@@ -132,17 +134,20 @@ pub struct Persistent<K: UnifyKey> {
132
134
values : DVec < VarValue < K > >
133
135
}
134
136
137
+ // HACK(eddyb) manual impl avoids `Default` bound on `K`.
138
+ #[ cfg( feature = "persistent" ) ]
139
+ impl < K : UnifyKey > Default for Persistent < K > {
140
+ fn default ( ) -> Self {
141
+ Persistent { values : DVec :: new ( ) }
142
+ }
143
+ }
144
+
135
145
#[ cfg( feature = "persistent" ) ]
136
146
impl < K : UnifyKey > UnificationStore for Persistent < K > {
137
147
type Key = K ;
138
148
type Value = K :: Value ;
139
149
type Snapshot = Self ;
140
150
141
- #[ inline]
142
- fn new ( ) -> Self {
143
- Persistent { values : DVec :: new ( ) }
144
- }
145
-
146
151
#[ inline]
147
152
fn start_snapshot ( & mut self ) -> Self :: Snapshot {
148
153
self . clone ( )
0 commit comments