Trait backtracking_iterator::Walkbackable
source · pub trait Walkbackable<'history> {
type RefPoint;
type Item;
type Walkback: Walkback<'history, Item = Self::Item, RefPoint = Self::RefPoint>;
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
Required Methods
sourcefn walk_back(&'history self) -> Self::Walkback
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);