@@ -187,13 +187,15 @@ tuple_upcast!(Vec: A, B, C, D);
187
187
#[ derive( Copy , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
188
188
pub struct Cons < T , C > ( pub T , pub C ) ;
189
189
190
- impl < T , U > UpcastFrom < Cons < U , Set < T > > > for Set < T >
190
+ impl < T , U , V > UpcastFrom < Cons < U , Set < V > > > for Set < T >
191
191
where
192
192
T : Ord + Clone ,
193
193
U : Upcast < T > ,
194
+ V : Ord + Upcast < T > ,
194
195
{
195
- fn upcast_from ( term : Cons < U , Set < T > > ) -> Self {
196
- let Cons ( elem, mut set) = term;
196
+ fn upcast_from ( term : Cons < U , Set < V > > ) -> Self {
197
+ let Cons ( elem, set) = term;
198
+ let mut set: Set < T > = set. upcast ( ) ;
197
199
set. insert ( elem. upcast ( ) ) ;
198
200
set
199
201
}
@@ -214,15 +216,16 @@ where
214
216
}
215
217
}
216
218
217
- impl < T , U > UpcastFrom < Cons < U , Vec < T > > > for Vec < T >
219
+ impl < T , U , V > UpcastFrom < Cons < U , Vec < V > > > for Vec < T >
218
220
where
219
- T : Ord + Clone ,
220
221
U : Upcast < T > ,
222
+ V : Upcast < T > ,
221
223
{
222
- fn upcast_from ( term : Cons < U , Vec < T > > ) -> Self {
223
- let Cons ( elem, mut vec) = term;
224
- vec. insert ( 0 , elem. upcast ( ) ) ;
225
- vec
224
+ fn upcast_from ( term : Cons < U , Vec < V > > ) -> Self {
225
+ let Cons ( elem, vec) = term;
226
+ std:: iter:: once ( elem. upcast ( ) )
227
+ . chain ( vec. into_iter ( ) . upcasted ( ) )
228
+ . collect ( )
226
229
}
227
230
}
228
231
0 commit comments