rmptuisrclist.rs
| 1 | #[derive(Debug)] |
| 2 | pub struct ContentList<T> { |
| 3 | pub list: Vec<T>, |
| 4 | pub index: usize |
| 5 | } |
| 6 | |
| 7 | impl<T> ContentList<T> { |
| 8 | pub fn new() -> Self { |
| 9 | ContentList { |
| 10 | list: Vec::new(), |
| 11 | index: 0 |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | // Go to next item in list |
| 16 | pub fn next(&mut self) { |
| 17 | self.index += 1; |
| 18 | } |
| 19 | |
| 20 | /// Go to previous item in list |
| 21 | pub fn prev(&mut self) { |
| 22 | if self.index != 0 { |
| 23 | self.index -= 1; |
| 24 | } |
| 25 | } |
| 26 | } |