Struct froggy::CursorItem [] [src]

pub struct CursorItem<'a, T: 'a> { /* fields omitted */ }

Item of the streaming iterator.

Cursor and CursorItem are extremely useful when you need to iterate over Pointers in storage with ability to get other component in the same storage during iterating.

Examples

Unfortunately, you can't use common for loop, but you can use while let statement:

let mut cursor = storage.cursor();
while let Some(item) = cursor.next() {
   // ... your code
}

While iterating, you can pin item with Pointer.

#[derive(Debug, PartialEq)]
struct Node {
   pointer: Option<WeakPointer<Node>>,
}
//...
let mut cursor = storage.cursor();
while let Some((left, mut item, _)) = cursor.next() {
   // let's look for the other Node
   match item.pointer {
       Some(ref pointer) => {
           let ref pointer = pointer.upgrade()?;
           if let Some(ref other_node) = left.get(pointer) {
               do_something(other_node);
           }
       },
       None => {},
   }
}

Methods

impl<'a, T> CursorItem<'a, T>
[src]

[src]

Pin the item with a strong pointer.

Trait Implementations

impl<'a, T: Debug + 'a> Debug for CursorItem<'a, T>
[src]

[src]

Formats the value using the given formatter.

impl<'a, T> Deref for CursorItem<'a, T>
[src]

The resulting type after dereferencing.

[src]

Dereferences the value.

impl<'a, T> DerefMut for CursorItem<'a, T>
[src]

[src]

Mutably dereferences the value.