@@ -24,7 +24,7 @@ use convert::AsRef;
2424use default:: Default ;
2525use fmt;
2626use iter:: ExactSizeIterator ;
27- use iter:: { Map , Iterator , DoubleEndedIterator } ;
27+ use iter:: { Map , Cloned , Iterator , DoubleEndedIterator } ;
2828use marker:: Sized ;
2929use mem;
3030use ops:: { Fn , FnMut , FnOnce } ;
@@ -369,34 +369,7 @@ impl<'a> CharIndices<'a> {
369369/// Created with the method `.bytes()`.
370370#[ stable( feature = "rust1" , since = "1.0.0" ) ]
371371#[ 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 > > ) ;
400373
401374#[ stable( feature = "rust1" , since = "1.0.0" ) ]
402375impl < ' a > Iterator for Bytes < ' a > {
@@ -1332,7 +1305,7 @@ impl StrExt for str {
13321305
13331306 #[ inline]
13341307 fn bytes ( & self ) -> Bytes {
1335- Bytes ( self . as_bytes ( ) . iter ( ) . map ( BytesDeref ) )
1308+ Bytes ( self . as_bytes ( ) . iter ( ) . cloned ( ) )
13361309 }
13371310
13381311 #[ inline]
0 commit comments