mabel/src/cursor.rs

18 lines
364 B
Rust
Raw Normal View History

2023-07-13 15:43:05 +00:00
pub struct CursorList<T, C> {
pub items: Vec<T>,
pub next_cursor: Option<C>,
}
pub trait AsCursor<C> {
fn cursor(&self) -> C;
}
impl<T: AsCursor<C>, C> CursorList<T, C> {
pub fn new(items: Vec<T>, limit: usize) -> Self {
CursorList {
next_cursor: items.get(limit - 1).map(|x| x.cursor()),
items,
}
}
}