1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pub mod cursor;

pub mod prelude {
    pub use super::{
        Down, DownMut, OpaqueVerticalCursor, VerticalCursor, VerticalCursorMut,
    };
}

#[cfg(test)]
mod tests;

pub trait Down {
    fn down(&self, idx: usize) -> Option<&Self>;
}

pub trait DownMut {
    fn down_mut(&mut self, idx: usize) -> Option<&mut Self>;
}

pub trait OpaqueVerticalCursor {
    fn zero(&mut self);
    fn down(&mut self) -> bool;
    fn up(&mut self) -> bool;
}

pub trait VerticalCursor: OpaqueVerticalCursor
where
    Self: Sized,
{
    type Item;

    fn get(&self) -> &Self::Item;
    fn down_new(&mut self) -> Option<Self>;
}

pub trait VerticalCursorMut: VerticalCursor {
    fn get_mut(&mut self) -> &mut Self::Item;
}