pub struct BacktrackingRecorder<Iter>where
    Iter: Iterator,
{ /* private fields */ }
Expand description

A wrapper around an existing iterator to give it a historical representation with the ability to then produce copying and referencing backtracking iterators on the history

Implementations

Create a BacktrackingRecorder from an existing iterator.

Take all items out of the history.

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

let vec_iter = vec![1_u8, 2, 3].into_iter();
let mut rec = BacktrackingRecorder::new(vec_iter);

{
  let mut bt_ref = rec.referencing();
  bt_ref.next(); // 1_u8
}

let mut history = rec.drain_history().into_iter();
// Repeats only what was in the history
assert!(history.next().unwrap() == 1_u8);
assert!(history.next().is_none());

Trait Implementations

Destroy the record and return an iterator which starts from the beginning of the history and chains into the originally-given iterator

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

let vec_iter = vec![1_u8, 2, 3].into_iter();
let mut rec = BacktrackingRecorder::new(vec_iter);

{
  let mut bt_ref = rec.referencing();
  bt_ref.next(); // 1_u8
}

let mut rec_iter = rec.into_iter();
// Repeats the value in the history
assert!(rec_iter.next().unwrap() == 1_u8);
// And follows up with the ones not yet recorded
assert!(rec_iter.next().unwrap() == 2_u8);
assert!(rec_iter.next().unwrap() == 3_u8);
assert!(rec_iter.next().is_none());
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
The type used to refer to positions in the history
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 Read more
Eliminate all the values before the given reference point from the history
Forget all the values before the current position in the iterator Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.