pub trait Cursor {
    type Offset;
    type Item;

    fn get_offset(&self) -> Self::Offset;
    fn set_offset(&mut self, offset: Self::Offset);
    fn get(&self) -> Option<Self::Item>;
    fn advance(&mut self, direction: Direction) -> Result<bool>;

    fn next(&mut self, direction: Direction) -> Result<Option<Self::Item>> { ... }
}
Expand description

A read-only Iterator that can move back and forth.

Required Associated Types

Required Methods

Get offset of the cursor.

Set offset of the cursor.

Get the item pointed to by the cursor. Could be None if item is invalid.

Move the cursor one step in the given direction if it’s within range. Return if the cursor is moved.

Provided Methods

Move the cursor in the given direction until a valid item is obtained. If no more valid item available, return None and offset unchanged.

Implementors