From 10c33b8172246999cb0f2b32a68e906a7da0b714 Mon Sep 17 00:00:00 2001 From: Sidney Cammeresi Date: Thu, 16 Apr 2026 13:49:55 -0700 Subject: [PATCH] Fix clippy, formatting, and increase errors from CI --- .github/workflows/ci.yml | 4 ++-- src/input.rs | 8 ++++---- src/input/tests.rs | 15 ++++++++++++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6254477..936478e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,6 @@ jobs: - name: Run tests run: cargo test - name: Run lint - run: cargo clippy + run: cargo clippy -- -D warnings - name: Run fmt - run: cargo fmt + run: cargo fmt --check diff --git a/src/input.rs b/src/input.rs index 5d3631c..eade409 100644 --- a/src/input.rs +++ b/src/input.rs @@ -59,11 +59,11 @@ fn is_word(s: &str) -> bool { } fn prev_word_byte(s: &str, byte: usize) -> usize { - let mut words = s + let words = s .split_word_bound_indices() .filter(|(i, _)| *i < byte) .rev(); - while let Some((i, word)) = words.next() { + for (i, word) in words { if is_word(word) { return i; } @@ -72,8 +72,8 @@ fn prev_word_byte(s: &str, byte: usize) -> usize { } fn next_word_byte(s: &str, byte: usize) -> usize { - let mut words = s.split_word_bound_indices().filter(|(i, _)| *i > byte); - while let Some((i, word)) = words.next() { + let words = s.split_word_bound_indices().filter(|(i, _)| *i > byte); + for (i, word) in words { if is_word(word) { return i; } diff --git a/src/input/tests.rs b/src/input/tests.rs index 6c44ee7..2644013 100644 --- a/src/input/tests.rs +++ b/src/input/tests.rs @@ -1,4 +1,3 @@ - const TEXT: &str = "first second, third."; use super::*; @@ -391,7 +390,12 @@ fn word_movement_comprehensive() { // Next word input.handle(InputRequest::GoToNextWord); - assert_eq!(input.value()[codepoint_to_byte(&input.value, input.cursor())..].chars().next(), Some('w')); + assert_eq!( + input.value()[codepoint_to_byte(&input.value, input.cursor())..] + .chars() + .next(), + Some('w') + ); input.handle(InputRequest::GoToNextWord); // "🤦🏼‍♂️" is now considered a word. @@ -428,7 +432,12 @@ fn word_movement_comprehensive() { ); input.handle(InputRequest::GoToPrevWord); - assert_eq!(input.value()[codepoint_to_byte(&input.value, input.cursor())..].chars().next(), Some('H')); + assert_eq!( + input.value()[codepoint_to_byte(&input.value, input.cursor())..] + .chars() + .next(), + Some('H') + ); } #[test]