aboutsummaryrefslogtreecommitdiff
path: root/src/list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.rs')
-rwxr-xr-xsrc/list.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/list.rs b/src/list.rs
index 74790a1..d5d5524 100755
--- a/src/list.rs
+++ b/src/list.rs
@@ -1,20 +1,28 @@
#[derive(Debug)]
pub struct ContentList<T> {
pub list: Vec<T>,
- pub index: usize
+ pub index: usize,
}
impl<T> ContentList<T> {
pub fn new() -> Self {
ContentList {
list: Vec::new(),
- index: 0
+ index: 0,
}
}
// Go to next item in list
pub fn next(&mut self) {
- self.index += 1;
+ // if self.index < self.list.len() - 1 {
+ // self.index += 1;
+ // }
+
+ if self.index == self.list.len() - 1 {
+ self.index = 0;
+ } else {
+ self.index += 1;
+ }
}
/// Go to previous item in list