commit a90645d475bee11150f1ffa1fb53a1e04533a64b
parent 69e93b0ebfef424d9ad5ee91faadb59ef06c2585
Author: William Casarin <jb55@jb55.com>
Date: Fri, 6 Dec 2024 09:43:09 -0800
simplify `prev` function
Thanks chatgpt, I thought this was more verbose than it could have been.
Changelog-None:
Signed-off-by: William Casarin <jb55@jb55.com>
Diffstat:
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/src/ui/column/header.rs b/src/ui/column/header.rs
@@ -240,13 +240,7 @@ impl<'a> NavTitle<'a> {
}
fn prev<R>(xs: &[R]) -> Option<&R> {
- let len = xs.len() as i32;
- let ind = len - 2;
- if ind < 0 {
- None
- } else {
- Some(&xs[ind as usize])
- }
+ xs.get(xs.len().checked_sub(2)?)
}
fn chevron(