October 2019
Intermediate to advanced
444 pages
10h 37m
English
Iterators are typically their own structs and, since there can be different types (for example, for returning references instead of owned values), they are a good choice architecturally as well:
pub struct ConsumingListIterator<T>where T: Clone + Sized,{ list: List<T>,}impl<T> ConsumingListIterator<T>where T: Clone + Sized,{ fn new(list: List<T>) -> ConsumingListIterator<T> { ConsumingListIterator { list: list } }}
Read now
Unlock full access