@@ -24,7 +24,7 @@ use convert::AsRef;
24
24
use default:: Default ;
25
25
use fmt;
26
26
use iter:: ExactSizeIterator ;
27
- use iter:: { Map , Iterator , DoubleEndedIterator } ;
27
+ use iter:: { Map , Cloned , Iterator , DoubleEndedIterator } ;
28
28
use marker:: Sized ;
29
29
use mem;
30
30
use ops:: { Fn , FnMut , FnOnce } ;
@@ -369,34 +369,7 @@ impl<'a> CharIndices<'a> {
369
369
/// Created with the method `.bytes()`.
370
370
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
371
371
#[ derive( Clone ) ]
372
- pub struct Bytes < ' a > ( Map < slice:: Iter < ' a , u8 > , BytesDeref > ) ;
373
-
374
- /// A nameable, clonable fn type
375
- #[ derive( Clone ) ]
376
- struct BytesDeref ;
377
-
378
- impl < ' a > Fn < ( & ' a u8 , ) > for BytesDeref {
379
- #[ inline]
380
- extern "rust-call" fn call ( & self , ( ptr, ) : ( & ' a u8 , ) ) -> u8 {
381
- * ptr
382
- }
383
- }
384
-
385
- impl < ' a > FnMut < ( & ' a u8 , ) > for BytesDeref {
386
- #[ inline]
387
- extern "rust-call" fn call_mut ( & mut self , ( ptr, ) : ( & ' a u8 , ) ) -> u8 {
388
- Fn :: call ( & * self , ( ptr, ) )
389
- }
390
- }
391
-
392
- impl < ' a > FnOnce < ( & ' a u8 , ) > for BytesDeref {
393
- type Output = u8 ;
394
-
395
- #[ inline]
396
- extern "rust-call" fn call_once ( self , ( ptr, ) : ( & ' a u8 , ) ) -> u8 {
397
- Fn :: call ( & self , ( ptr, ) )
398
- }
399
- }
372
+ pub struct Bytes < ' a > ( Cloned < slice:: Iter < ' a , u8 > > ) ;
400
373
401
374
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
402
375
impl < ' a > Iterator for Bytes < ' a > {
@@ -1347,7 +1320,7 @@ impl StrExt for str {
1347
1320
1348
1321
#[ inline]
1349
1322
fn bytes ( & self ) -> Bytes {
1350
- Bytes ( self . as_bytes ( ) . iter ( ) . map ( BytesDeref ) )
1323
+ Bytes ( self . as_bytes ( ) . iter ( ) . cloned ( ) )
1351
1324
}
1352
1325
1353
1326
#[ inline]
0 commit comments