aboutsummaryrefslogtreecommitdiff
path: root/src/list.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/list.rs')
-rwxr-xr-xsrc/list.rs32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/list.rs b/src/list.rs
index 6294f44..219b9a4 100755
--- a/src/list.rs
+++ b/src/list.rs
@@ -14,30 +14,36 @@ impl<T> ContentList<T> {
// Go to next item in list
pub fn next(&mut self) {
- // if self.index < self.list.len() - 1 {
- // self.index += 1;
- // }
-
let len = self.list.len();
if len != 0 {
- if self.index == self.list.len() - 1 {
- self.index = 0;
- } else {
+ if self.index < len - 1 {
self.index += 1;
}
}
+
+ // let len = self.list.len();
+ // if len != 0 {
+ // if self.index == self.list.len() - 1 {
+ // self.index = 0;
+ // } else {
+ // self.index += 1;
+ // }
+ // }
}
/// Go to previous item in list
pub fn prev(&mut self) {
- if self.index == 0 {
- let len = self.list.len();
- if len != 0 {
- self.index = len - 1;
- }
- } else {
+ if self.index != 0 {
self.index -= 1;
}
+ // if self.index == 0 {
+ // let len = self.list.len();
+ // if len != 0 {
+ // self.index = len - 1;
+ // }
+ // } else {
+ // self.index -= 1;
+ // }
}
pub fn reset_index(&mut self) {