@@ -65,7 +65,7 @@ use default::Default;
65
65
use marker;
66
66
use mem;
67
67
use num:: { ToPrimitive , Int } ;
68
- use ops:: { Add , Deref , FnMut , RangeFrom } ;
68
+ use ops:: { Add , FnMut , RangeFrom } ;
69
69
use option:: Option ;
70
70
use option:: Option :: { Some , None } ;
71
71
use marker:: Sized ;
@@ -976,12 +976,11 @@ pub trait IteratorExt: Iterator + Sized {
976
976
( ts, us)
977
977
}
978
978
979
- /// Creates an iterator that clones the elements it yields. Useful for converting an
980
- /// Iterator<&T> to an Iterator<T>.
981
- #[ unstable( feature = "core" , reason = "recent addition" ) ]
982
- fn cloned ( self ) -> Cloned < Self > where
983
- Self :: Item : Deref ,
984
- <Self :: Item as Deref >:: Target : Clone ,
979
+ /// Creates an iterator that clones the elements it yields. Useful for
980
+ /// converting an Iterator<&T> to an Iterator<T>.
981
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
982
+ fn cloned < ' a , T : ' a > ( self ) -> Cloned < Self >
983
+ where Self : Iterator < Item =& ' a T > , T : Clone
985
984
{
986
985
Cloned { it : self }
987
986
}
@@ -1279,14 +1278,12 @@ pub struct Cloned<I> {
1279
1278
}
1280
1279
1281
1280
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1282
- impl < I > Iterator for Cloned < I > where
1283
- I : Iterator ,
1284
- I :: Item : Deref ,
1285
- <I :: Item as Deref >:: Target : Clone
1281
+ impl < ' a , I , T : ' a > Iterator for Cloned < I >
1282
+ where I : Iterator < Item =& ' a T > , T : Clone
1286
1283
{
1287
- type Item = < I :: Item as Deref > :: Target ;
1284
+ type Item = T ;
1288
1285
1289
- fn next ( & mut self ) -> Option < < Self as Iterator > :: Item > {
1286
+ fn next ( & mut self ) -> Option < T > {
1290
1287
self . it . next ( ) . cloned ( )
1291
1288
}
1292
1289
@@ -1296,36 +1293,30 @@ impl<I> Iterator for Cloned<I> where
1296
1293
}
1297
1294
1298
1295
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1299
- impl < I > DoubleEndedIterator for Cloned < I > where
1300
- I : DoubleEndedIterator ,
1301
- I :: Item : Deref ,
1302
- <I :: Item as Deref >:: Target : Clone
1296
+ impl < ' a , I , T : ' a > DoubleEndedIterator for Cloned < I >
1297
+ where I : DoubleEndedIterator < Item =& ' a T > , T : Clone
1303
1298
{
1304
- fn next_back ( & mut self ) -> Option < < Self as Iterator > :: Item > {
1299
+ fn next_back ( & mut self ) -> Option < T > {
1305
1300
self . it . next_back ( ) . cloned ( )
1306
1301
}
1307
1302
}
1308
1303
1309
1304
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1310
- impl < I > ExactSizeIterator for Cloned < I > where
1311
- I : ExactSizeIterator ,
1312
- I :: Item : Deref ,
1313
- <I :: Item as Deref >:: Target : Clone
1305
+ impl < ' a , I , T : ' a > ExactSizeIterator for Cloned < I >
1306
+ where I : ExactSizeIterator < Item =& ' a T > , T : Clone
1314
1307
{ }
1315
1308
1316
1309
#[ unstable( feature = "core" , reason = "trait is experimental" ) ]
1317
- impl < I > RandomAccessIterator for Cloned < I > where
1318
- I : RandomAccessIterator ,
1319
- I :: Item : Deref ,
1320
- <I :: Item as Deref >:: Target : Clone
1310
+ impl < ' a , I , T : ' a > RandomAccessIterator for Cloned < I >
1311
+ where I : RandomAccessIterator < Item =& ' a T > , T : Clone
1321
1312
{
1322
1313
#[ inline]
1323
1314
fn indexable ( & self ) -> usize {
1324
1315
self . it . indexable ( )
1325
1316
}
1326
1317
1327
1318
#[ inline]
1328
- fn idx ( & mut self , index : usize ) -> Option < < Self as Iterator > :: Item > {
1319
+ fn idx ( & mut self , index : usize ) -> Option < T > {
1329
1320
self . it . idx ( index) . cloned ( )
1330
1321
}
1331
1322
}
0 commit comments