11pub mod ListExt {
22 // use core::ops::Deref;
3- use crate :: List_ :: { cons, empty, isEmpty, reverse, List } ;
4- use crate :: Native_ :: { seq_to_iter , NullableRef , Vec } ;
3+ use crate :: List_ :: { List , cons, empty, isEmpty, reverse} ;
4+ use crate :: Native_ :: { NullableRef , Vec , seq_to_iter } ;
55 use crate :: Seq_ :: ofList;
66
77 impl < T : Clone > List < T > {
@@ -75,12 +75,12 @@ pub mod ListExt {
7575}
7676
7777pub mod SetExt {
78- use crate :: Native_ :: { make_compare , seq_to_iter , Func2 , NullableRef , Vec } ;
79- use crate :: Set_ :: { add, compareTo, empty, equals, isEmpty, toSeq, Set } ;
78+ use crate :: Native_ :: { Func2 , Hashable , NullableRef , Vec , make_compare , seq_to_iter } ;
79+ use crate :: Set_ :: { Set , add, compareTo, empty, equals, isEmpty, toSeq} ;
8080 use core:: cmp:: Ordering ;
8181 use core:: hash:: { Hash , Hasher } ;
8282
83- impl < T : Clone + PartialOrd > Set < T > {
83+ impl < T : Clone + Hashable + PartialOrd > Set < T > {
8484 //todo - non-consuming iter by ref
8585 // pub fn iter<'a>(&self) -> impl Iterator<Item = & 'a T> {
8686 // let s = toSeq(self.clone());
@@ -105,34 +105,34 @@ pub mod SetExt {
105105 }
106106 }
107107
108- impl < T : Clone + PartialOrd > PartialEq for Set < T > {
108+ impl < T : Clone + Hashable + PartialOrd > PartialEq for Set < T > {
109109 fn eq ( & self , other : & Self ) -> bool {
110110 equals ( self . clone ( ) , other. clone ( ) )
111111 }
112112 }
113113
114- impl < T : Clone + PartialOrd > Eq for Set < T > { }
114+ impl < T : Clone + Hashable + PartialOrd > Eq for Set < T > { }
115115
116- impl < T : Clone + PartialOrd + Hash > Hash for Set < T > {
116+ impl < T : Clone + Hashable + PartialOrd + Hash > Hash for Set < T > {
117117 fn hash < H : Hasher > ( & self , state : & mut H ) {
118118 let s = toSeq ( self . clone ( ) ) ;
119119 seq_to_iter ( s) . for_each ( |x| x. hash ( state) )
120120 }
121121 }
122122
123- impl < T : Clone + PartialOrd > PartialOrd for Set < T > {
123+ impl < T : Clone + Hashable + PartialOrd > PartialOrd for Set < T > {
124124 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
125125 Some ( make_compare ( Func2 :: from ( compareTo) ) ( self , other) )
126126 }
127127 }
128128
129- impl < T : Clone + PartialOrd > Ord for Set < T > {
129+ impl < T : Clone + Hashable + PartialOrd > Ord for Set < T > {
130130 fn cmp ( & self , other : & Self ) -> Ordering {
131131 make_compare ( Func2 :: from ( compareTo) ) ( self , other)
132132 }
133133 }
134134
135- impl < T : Clone + PartialOrd > From < Vec < T > > for Set < T > {
135+ impl < T : Clone + Hashable + PartialOrd > From < Vec < T > > for Set < T > {
136136 fn from ( vec : Vec < T > ) -> Self {
137137 let mut set = empty ( ) ;
138138 for v in vec. iter ( ) {
@@ -142,7 +142,7 @@ pub mod SetExt {
142142 }
143143 }
144144
145- impl < T : Clone + PartialOrd > From < & Vec < T > > for Set < T > {
145+ impl < T : Clone + Hashable + PartialOrd > From < & Vec < T > > for Set < T > {
146146 fn from ( vec : & Vec < T > ) -> Self {
147147 let mut set = empty ( ) ;
148148 for v in vec. iter ( ) {
@@ -152,7 +152,7 @@ pub mod SetExt {
152152 }
153153 }
154154
155- impl < T : Clone + PartialOrd > FromIterator < T > for Set < T > {
155+ impl < T : Clone + Hashable + PartialOrd > FromIterator < T > for Set < T > {
156156 fn from_iter < U : IntoIterator < Item = T > > ( iter : U ) -> Self {
157157 let mut set = empty ( ) ;
158158 for v in iter. into_iter ( ) {
@@ -162,20 +162,20 @@ pub mod SetExt {
162162 }
163163 }
164164
165- impl < T : Clone + PartialOrd > Into < Vec < T > > for Set < T > {
165+ impl < T : Clone + Hashable + PartialOrd > Into < Vec < T > > for Set < T > {
166166 fn into ( self ) -> Vec < T > {
167167 self . into_iter ( ) . collect ( )
168168 }
169169 }
170170}
171171
172172pub mod MapExt {
173- use crate :: Map_ :: { add, compareTo, empty, equals, isEmpty, iterate, toSeq, Map } ;
174- use crate :: Native_ :: { make_compare , seq_to_iter , Func2 , NullableRef , Vec } ;
173+ use crate :: Map_ :: { Map , add, compareTo, empty, equals, isEmpty, iterate, toSeq} ;
174+ use crate :: Native_ :: { Func2 , Hashable , NullableRef , Vec , make_compare , seq_to_iter } ;
175175 use core:: cmp:: Ordering ;
176176 use core:: hash:: { Hash , Hasher } ;
177177
178- impl < K : Clone + PartialOrd , V : Clone > Map < K , V > {
178+ impl < K : Clone + Hashable + PartialOrd , V : Clone > Map < K , V > {
179179 //todo - non-consuming iter by ref
180180 // pub fn iter<'a>(&self) -> impl Iterator<Item = (& 'a K, & 'a V)> {
181181 // let s = toSeq(self.clone());
@@ -188,7 +188,7 @@ pub mod MapExt {
188188 }
189189 }
190190
191- impl < K : Clone + PartialOrd , V : Clone > NullableRef for Map < K , V > {
191+ impl < K : Clone + Hashable + PartialOrd , V : Clone > NullableRef for Map < K , V > {
192192 #[ inline]
193193 fn null ( ) -> Self {
194194 empty ( )
@@ -200,34 +200,34 @@ pub mod MapExt {
200200 }
201201 }
202202
203- impl < K : Clone + PartialOrd , V : Clone + PartialOrd > PartialEq for Map < K , V > {
203+ impl < K : Clone + Hashable + PartialOrd , V : Clone + Hashable + PartialOrd > PartialEq for Map < K , V > {
204204 fn eq ( & self , other : & Self ) -> bool {
205205 equals ( self . clone ( ) , other. clone ( ) )
206206 }
207207 }
208208
209- impl < K : Clone + PartialOrd , V : Clone + PartialOrd > Eq for Map < K , V > { }
209+ impl < K : Clone + Hashable + PartialOrd , V : Clone + Hashable + PartialOrd > Eq for Map < K , V > { }
210210
211- impl < K : Clone + PartialOrd + Hash , V : Clone + Hash > Hash for Map < K , V > {
211+ impl < K : Clone + Hashable + PartialOrd + Hash , V : Clone + Hash > Hash for Map < K , V > {
212212 fn hash < H : Hasher > ( & self , state : & mut H ) {
213213 let s = toSeq ( self . clone ( ) ) ;
214214 seq_to_iter ( s) . for_each ( |kvp| kvp. hash ( state) )
215215 }
216216 }
217217
218- impl < K : Clone + PartialOrd , V : Clone + PartialOrd > PartialOrd for Map < K , V > {
218+ impl < K : Clone + Hashable + PartialOrd , V : Clone + Hashable + PartialOrd > PartialOrd for Map < K , V > {
219219 fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
220220 Some ( make_compare ( Func2 :: from ( compareTo) ) ( self , other) )
221221 }
222222 }
223223
224- impl < K : Clone + PartialOrd , V : Clone + PartialOrd > Ord for Map < K , V > {
224+ impl < K : Clone + Hashable + PartialOrd , V : Clone + Hashable + PartialOrd > Ord for Map < K , V > {
225225 fn cmp ( & self , other : & Self ) -> Ordering {
226226 make_compare ( Func2 :: from ( compareTo) ) ( self , other)
227227 }
228228 }
229229
230- impl < K : Clone + PartialOrd , V : Clone > From < & Vec < ( K , V ) > > for Map < K , V > {
230+ impl < K : Clone + Hashable + PartialOrd , V : Clone > From < & Vec < ( K , V ) > > for Map < K , V > {
231231 fn from ( vec : & Vec < ( K , V ) > ) -> Self {
232232 let mut map: Map < K , V > = empty ( ) ;
233233 for ( i, ( k, v) ) in vec. iter ( ) . rev ( ) . enumerate ( ) {
@@ -237,7 +237,7 @@ pub mod MapExt {
237237 }
238238 }
239239
240- impl < K : Clone + PartialOrd , V : Clone > FromIterator < ( K , V ) > for Map < K , V > {
240+ impl < K : Clone + Hashable + PartialOrd , V : Clone > FromIterator < ( K , V ) > for Map < K , V > {
241241 fn from_iter < U : IntoIterator < Item = ( K , V ) > > ( iter : U ) -> Self {
242242 let mut map: Map < K , V > = empty ( ) ;
243243 for ( k, v) in iter. into_iter ( ) {
@@ -247,7 +247,7 @@ pub mod MapExt {
247247 }
248248 }
249249
250- impl < K : Clone + PartialOrd , V : Clone > Into < Vec < ( K , V ) > > for Map < K , V > {
250+ impl < K : Clone + Hashable + PartialOrd , V : Clone > Into < Vec < ( K , V ) > > for Map < K , V > {
251251 fn into ( self ) -> Vec < ( K , V ) > {
252252 self . into_iter ( ) . collect ( )
253253 }
0 commit comments