pub struct Cursor<'a, T: 'a> { /* private fields */ }Expand description
Streaming iterator providing mutable components and a capability to look back/ahead.
See documentation of CursorItem.
Implementations§
Source§impl<'a, T> Cursor<'a, T>
impl<'a, T> Cursor<'a, T>
Sourcepub fn next(
&mut self,
) -> Option<(Slice<'_, T>, CursorItem<'_, T>, Slice<'_, T>)>
pub fn next( &mut self, ) -> Option<(Slice<'_, T>, CursorItem<'_, T>, Slice<'_, T>)>
Advance the stream to the next item.
Examples found in repository?
examples/cursor.rs (line 30)
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}Trait Implementations§
Auto Trait Implementations§
impl<'a, T> Freeze for Cursor<'a, T>
impl<'a, T> !RefUnwindSafe for Cursor<'a, T>
impl<'a, T> Send for Cursor<'a, T>where
T: Send,
impl<'a, T> Sync for Cursor<'a, T>where
T: Sync,
impl<'a, T> Unpin for Cursor<'a, T>
impl<'a, T> !UnwindSafe for Cursor<'a, T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more