mirror of
https://github.com/LGUG2Z/komorebi.git
synced 2026-09-16 23:01:30 +02:00
Realised that I hadn't turned on super pedantic mode for clippy in the komorebi-core and komorebic crates. This commit ensures the same clippy config across all crates and applies the lint suggestions that arose as a result of turning on the same config everywhere.
35 lines
796 B
Rust
35 lines
796 B
Rust
use clap::ArgEnum;
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
use strum::Display;
|
|
use strum::EnumString;
|
|
|
|
#[derive(Clone, Copy, Debug, Serialize, Deserialize, Display, EnumString, ArgEnum)]
|
|
#[strum(serialize_all = "snake_case")]
|
|
pub enum CycleDirection {
|
|
Previous,
|
|
Next,
|
|
}
|
|
|
|
impl CycleDirection {
|
|
#[must_use]
|
|
pub const fn next_idx(&self, idx: usize, len: usize) -> usize {
|
|
match self {
|
|
CycleDirection::Previous => {
|
|
if idx == 0 {
|
|
len - 1
|
|
} else {
|
|
idx - 1
|
|
}
|
|
}
|
|
CycleDirection::Next => {
|
|
if idx == len - 1 {
|
|
0
|
|
} else {
|
|
idx + 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|