diff options
| author | krolxon <krolyxon@tutanota.com> | 2024-04-23 23:33:17 +0530 |
|---|---|---|
| committer | krolxon <krolyxon@tutanota.com> | 2024-04-23 23:33:17 +0530 |
| commit | b93eae44822168c0dab821a12fa3ecd62ee4a875 (patch) | |
| tree | 69f9737cd6d478c3ef038a41f89d8c75565d04c7 /src/list.rs | |
| parent | 05c4b17bc078df9c5694e450b72aecbed9fc5216 (diff) | |
add documentation
Diffstat (limited to 'src/list.rs')
| -rwxr-xr-x | src/list.rs | 14 |
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 |
