cursor/
cursor.rs

1extern crate froggy;
2
3struct Fibbo {
4    prev: Vec<froggy::Pointer<Fibbo>>,
5    value: i32,
6}
7
8fn main() {
9    let mut storage = froggy::Storage::new();
10    // initialize the first two Fibbo numbers
11    let mut first = storage.create(Fibbo {
12        prev: Vec::new(),
13        value: 1,
14    });
15    let mut second = storage.create(Fibbo {
16        prev: vec![first.clone()],
17        value: 0,
18    });
19    // initialize the other ones
20    for _ in 0 .. 10 {
21        let next = storage.create(Fibbo {
22            prev: vec![first, second.clone()],
23            value: 0,
24        });
25        first = second;
26        second = next;
27    }
28    // compute them with look-back
29    let mut cursor = storage.cursor();
30    cursor.next().unwrap(); //skip first
31    while let Some((left, mut item, _)) = cursor.next() {
32        item.value = item.prev.iter().map(|prev|
33            left.get(prev).unwrap().value
34            ).sum();
35        println!("{}", item.value);
36    }
37}