@@ -12,13 +12,13 @@ type Key<S> = <S as UnificationStore>::Key;
1212/// Largely internal trait implemented by the unification table
1313/// backing store types. The most common such type is `InPlace`,
1414/// 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+ {
1618 type Key : UnifyKey < Value = Self :: Value > ;
1719 type Value : UnifyValue ;
1820 type Snapshot ;
1921
20- fn new ( ) -> Self ;
21-
2222 fn start_snapshot ( & mut self ) -> Self :: Snapshot ;
2323
2424 fn rollback_to ( & mut self , snapshot : Self :: Snapshot ) ;
@@ -51,16 +51,18 @@ pub struct InPlace<K: UnifyKey> {
5151 values : sv:: SnapshotVec < Delegate < K > >
5252}
5353
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+
5461impl < K : UnifyKey > UnificationStore for InPlace < K > {
5562 type Key = K ;
5663 type Value = K :: Value ;
5764 type Snapshot = sv:: Snapshot ;
5865
59- #[ inline]
60- fn new ( ) -> Self {
61- InPlace { values : sv:: SnapshotVec :: new ( ) }
62- }
63-
6466 #[ inline]
6567 fn start_snapshot ( & mut self ) -> Self :: Snapshot {
6668 self . values . start_snapshot ( )
@@ -132,17 +134,20 @@ pub struct Persistent<K: UnifyKey> {
132134 values : DVec < VarValue < K > >
133135}
134136
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+
135145#[ cfg( feature = "persistent" ) ]
136146impl < K : UnifyKey > UnificationStore for Persistent < K > {
137147 type Key = K ;
138148 type Value = K :: Value ;
139149 type Snapshot = Self ;
140150
141- #[ inline]
142- fn new ( ) -> Self {
143- Persistent { values : DVec :: new ( ) }
144- }
145-
146151 #[ inline]
147152 fn start_snapshot ( & mut self ) -> Self :: Snapshot {
148153 self . clone ( )
0 commit comments