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