2015-11-04 17 views

Odpowiedz

6

Musi być w stanie zmutować self, ponieważ przesuwa iterator. Każdorazowe zadzwonić next, iterator jest zmutowany:

fn next(&mut self) -> Option<Self::Item>; 

Oto the implementation of find:

fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where 
    Self: Sized, 
    P: FnMut(&Self::Item) -> bool, 
{ 
    for x in self.by_ref() { 
     if predicate(&x) { return Some(x) } 
    } 
    None 
} 
+0

Dzięki. Tak oczywiste! –

Powiązane problemy