mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
chore(step): optimize positive and rename it
This commit is contained in:
parent
d8ac32f1fd
commit
5665096094
2 changed files with 8 additions and 6 deletions
|
|
@ -68,7 +68,7 @@ impl Tab {
|
|||
}
|
||||
|
||||
pub fn arrow(&mut self, step: Step) -> bool {
|
||||
let ok = if step.positive() { self.current.next(step) } else { self.current.prev(step) };
|
||||
let ok = if step.is_positive() { self.current.next(step) } else { self.current.prev(step) };
|
||||
if !ok {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ pub enum Step {
|
|||
}
|
||||
|
||||
impl Default for Step {
|
||||
#[inline]
|
||||
fn default() -> Self { Self::Fixed(0) }
|
||||
}
|
||||
|
||||
|
|
@ -22,10 +23,12 @@ impl FromStr for Step {
|
|||
}
|
||||
|
||||
impl From<isize> for Step {
|
||||
#[inline]
|
||||
fn from(n: isize) -> Self { Self::Fixed(n) }
|
||||
}
|
||||
|
||||
impl From<usize> for Step {
|
||||
#[inline]
|
||||
fn from(n: usize) -> Self { Self::Fixed(n as isize) }
|
||||
}
|
||||
|
||||
|
|
@ -46,11 +49,10 @@ impl Step {
|
|||
}
|
||||
|
||||
#[inline]
|
||||
pub fn positive(&self) -> bool {
|
||||
match self {
|
||||
Self::Fixed(n) if *n > 0 => true,
|
||||
Self::Percent(n) if *n > 0 => true,
|
||||
_ => false,
|
||||
pub fn is_positive(&self) -> bool {
|
||||
match *self {
|
||||
Self::Fixed(n) => n > 0,
|
||||
Self::Percent(n) => n > 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue