From 3f2faf4167a7783b30564c09d3b782938e35e3e0 Mon Sep 17 00:00:00 2001 From: James Campos Date: Tue, 21 Apr 2020 01:34:24 -0700 Subject: saturating --- src/main.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index e232c40..280aa2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -202,11 +202,7 @@ impl Bk { | KeyCode::PageUp | KeyCode::Char('h') => { if self.pos > 0 { - if self.pos < self.rows { - self.pos = 0; - } else { - self.pos -= self.rows; - } + self.pos = self.pos.saturating_sub(self.rows); } else if self.chapter_idx > 0 { self.get_chapter(self.chapter_idx - 1); self.pos = (self.chapter.len() / self.rows) * self.rows; -- cgit v1.2.3