Cursor

Trait Cursor 

Source
pub trait Cursor {
    type Offset;
    type Item;

    // Required methods
    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>;

    // Provided method
    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§

Source

fn get_offset(&self) -> Self::Offset

Get offset of the cursor.

Source

fn set_offset(&mut self, offset: Self::Offset)

Set offset of the cursor.

Source

fn get(&self) -> Option<Self::Item>

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

Source

fn advance(&mut self, direction: Direction) -> Result<bool>

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

Provided Methods§

Source

fn next(&mut self, direction: Direction) -> Result<Option<Self::Item>>

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§