@@ -428,9 +428,10 @@ pub trait Itertools : Iterator {
428
428
/// Find the position and value of the first element satisfying a predicate.
429
429
fn find_position < P > ( & mut self , mut pred : P ) -> Option < ( usize , Self :: Item ) > where
430
430
P : FnMut ( & Self :: Item ) -> bool ,
431
+ Self : Sized ,
431
432
{
432
433
let mut index = 0 us;
433
- for elt in * self {
434
+ for elt in IteratorExt :: by_ref ( self ) {
434
435
if pred ( & elt) {
435
436
return Some ( ( index, elt) )
436
437
}
@@ -477,27 +478,30 @@ pub trait Itertools : Iterator {
477
478
/// "hi".chars().map(|c| cnt += 1).drain();
478
479
/// ```
479
480
///
480
- fn drain ( & mut self )
481
+ fn drain ( & mut self ) where
482
+ Self : Sized
481
483
{
482
- for _ in * self { /* nothing */ }
484
+ for _ in self . by_ref ( ) { /* nothing */ }
483
485
}
484
486
485
487
/// Run the closure **f** eagerly on each element of the iterator.
486
488
///
487
489
/// Consumes the iterator until its end.
488
490
///
489
491
/// **Note: This method is deprecated, use .foreach() instead.**
490
- fn apply < F : FnMut ( Self :: Item ) > ( & mut self , f : F )
492
+ fn apply < F : FnMut ( Self :: Item ) > ( & mut self , f : F ) where
493
+ Self : Sized
491
494
{
492
495
self . foreach ( f)
493
496
}
494
497
495
498
/// Run the closure **f** eagerly on each element of the iterator.
496
499
///
497
500
/// Consumes the iterator until its end.
498
- fn foreach < F : FnMut ( Self :: Item ) > ( & mut self , mut f : F )
501
+ fn foreach < F : FnMut ( Self :: Item ) > ( & mut self , mut f : F ) where
502
+ Self : Sized
499
503
{
500
- for elt in * self { f ( elt) }
504
+ for elt in self . by_ref ( ) { f ( elt) }
501
505
}
502
506
503
507
/// **.collec_vec()** is simply a type specialization of **.collect()**,
@@ -517,7 +521,7 @@ impl<T: ?Sized> Itertools for T where T: Iterator { }
517
521
/// Return the number of elements written.
518
522
#[ inline]
519
523
pub fn write < ' a , A : ' a , I : Iterator < Item =& ' a mut A > , J : Iterator < Item =A > >
520
- ( mut to : I , mut from : J ) -> usize
524
+ ( mut to : I , from : J ) -> usize
521
525
{
522
526
let mut count = 0 ;
523
527
for elt in from {
0 commit comments