Trait Record

Source
pub trait Record {
    type RefPoint;

    // Required methods
    fn get_ref_point(&self) -> Self::RefPoint;
    fn forget_before(&mut self, point: Self::RefPoint);

    // Provided method
    fn forget(&mut self) { ... }
}
Expand description

A historical record representation

Required Associated Types§

Source

type RefPoint

The type used to refer to positions in the history

Required Methods§

Source

fn get_ref_point(&self) -> Self::RefPoint

Yield a reference to the current point in the history This reference must be valid for as long as the current point remains in the history

Source

fn forget_before(&mut self, point: Self::RefPoint)

Eliminate all the values before the given reference point from the history

Provided Methods§

Source

fn forget(&mut self)

Forget all the values before the current position in the iterator

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

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

//Before we call this, 1_u8 is in the history
rec.forget();

{
  let mut bt = rec.copying();
  assert!(bt.next().unwrap() == 2_u8);
}

Implementors§

Source§

impl<Iter> Record for BacktrackingRecorder<Iter>
where Iter: Iterator,