From b93eae44822168c0dab821a12fa3ecd62ee4a875 Mon Sep 17 00:00:00 2001 From: krolxon Date: Tue, 23 Apr 2024 23:33:17 +0530 Subject: add documentation --- src/list.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'src/list.rs') 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 { pub list: Vec, - pub index: usize + pub index: usize, } impl ContentList { 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 -- cgit v1.2.3