unsafe trait StepByImpl<I> {
    type Item;

    // Required methods
    fn spec_next(&mut self) -> Option<Self::Item>;
    fn spec_size_hint(&self) -> (usize, Option<usize>);
    fn spec_nth(&mut self, n: usize) -> Option<Self::Item>;
    fn spec_try_fold<Acc, F, R>(&mut self, acc: Acc, f: F) -> R
       where F: FnMut(Acc, Self::Item) -> R,
             R: Try<Output = Acc>;
    fn spec_fold<Acc, F>(self, acc: Acc, f: F) -> Acc
       where F: FnMut(Acc, Self::Item) -> Acc;
}
Expand description

Specialization trait to optimize StepBy<Range<{integer}>> iteration.

Safety

Technically this is safe to implement (look ma, no unsafe!), but in reality a lot of unsafe code relies on ranges over integers being correct.

For correctness all public StepBy methods must be specialized because setup drastically alters the meaning of the struct fields so that mixing different implementations would lead to incorrect results.

Required Associated Types§

Required Methods§

source

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

source

fn spec_size_hint(&self) -> (usize, Option<usize>)

source

fn spec_nth(&mut self, n: usize) -> Option<Self::Item>

source

fn spec_try_fold<Acc, F, R>(&mut self, acc: Acc, f: F) -> Rwhere F: FnMut(Acc, Self::Item) -> R, R: Try<Output = Acc>,

source

fn spec_fold<Acc, F>(self, acc: Acc, f: F) -> Accwhere F: FnMut(Acc, Self::Item) -> Acc,

Implementors§