Walkbackable

Trait Walkbackable 

Source
pub trait Walkbackable<'history> {
    type RefPoint;
    type Item;
    type Walkback: Walkback<'history, Item = Self::Item, RefPoint = Self::RefPoint>;

    // Required method
    fn walk_back(&'history self) -> Self::Walkback;
}
Expand description

An iterator that can be walked back on, parameterised for a lifetime This trait is a workaround for the lack of generic associated types - it is expected to be implemented for every lifetime, for reasons of utility

Required Associated Types§

Source

type RefPoint

The type used to refer to positions in the history

Source

type Item

The type of item in the history

Source

type Walkback: Walkback<'history, Item = Self::Item, RefPoint = Self::RefPoint>

The type of the walk-back iterator

Required Methods§

Source

fn walk_back(&'history self) -> Self::Walkback

Produce an iterator which goes back over the current history in reverse, and yields items in the history.

extern crate backtracking_iterator;
use backtracking_iterator::{BacktrackingIterator, Walkbackable};

let v = vec![1_u8, 2_u8];
let mut rec = backtracking_iterator::BacktrackingRecorder::new(v.into_iter());
let mut bt = rec.copying();
bt.next();

let mut wb = bt.walk_back();

assert!(wb.next().unwrap() == 1_u8);

Implementors§

Source§

impl<'history, 'record, I> Walkbackable<'history> for CopyingBacktrackingIterator<'record, I>
where I: Iterator + 'history, I::Item: Clone, 'history: 'record,

Source§

impl<'history, 'record, Iter> Walkbackable<'history> for ReferencingBacktrackingIterator<'record, Iter>
where Iter: Iterator + 'history, 'history: 'record,

Source§

type RefPoint = usize

Source§

type Item = &'record <Iter as Iterator>::Item

Source§

type Walkback = ReferencingWalkback<'record, Iter>