From 905038ba82679e0c65becd01577ada4c02f0138a Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 28 Nov 2026 13:44:19 +0100 Subject: [PATCH 1/2] Address three clippy lints One by using stringify for type name. --- Cargo.toml | 3 +++ src/arrayvec.rs | 1 + src/errors.rs | 2 +- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 3496e76d..a49c0721 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -64,3 +64,6 @@ features = ["borsh", "serde", "zeroize"] [package.metadata.release] no-dev-version = true tag-name = "{{version}}" + +[lints.clippy] +while_let_on_iterator = "allow" diff --git a/src/arrayvec.rs b/src/arrayvec.rs index aa314257..92d1bfce 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -1134,6 +1134,7 @@ impl ArrayVec { /// /// If CHECK is false, the iterator must yield at most `CAP - len()` elements. #[track_caller] + #[allow(clippy::explicit_counter_loop)] unsafe fn extend_from_iter(&mut self, iter: I) where I: Iterator { diff --git a/src/errors.rs b/src/errors.rs index 7ca3ebc4..fa96bc7c 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -43,7 +43,7 @@ impl fmt::Display for CapacityError { impl fmt::Debug for CapacityError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}: {}", "CapacityError", CAPERROR) + write!(f, "{}: {}", stringify!(CapacityError), CAPERROR) } } From 938fc9e3df496b514268099265ce81e30477d7b3 Mon Sep 17 00:00:00 2001 From: Ulrik Sverdrup Date: Sat, 28 Nov 2026 13:46:57 +0100 Subject: [PATCH 2/2] Auto-fix a bunch of clippy lints --- src/array_string.rs | 7 ++----- src/arrayvec.rs | 8 ++++---- src/errors.rs | 4 ++-- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/array_string.rs b/src/array_string.rs index 227e01db..2cd0f59b 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -311,10 +311,7 @@ impl ArrayString /// assert_eq!(s.pop(), None); /// ``` pub fn pop(&mut self) -> Option { - let ch = match self.chars().rev().next() { - Some(ch) => ch, - None => return None, - }; + let ch = self.chars().next_back()?; let new_len = self.len() - ch.len_utf8(); unsafe { self.set_len(new_len); @@ -686,7 +683,7 @@ impl<'a, const CAP: usize> TryFrom> for ArrayString fn try_from(f: fmt::Arguments<'a>) -> Result { use fmt::Write; let mut v = Self::new(); - v.write_fmt(f).map_err(|e| CapacityError::new(e))?; + v.write_fmt(f).map_err(CapacityError::new)?; Ok(v) } } diff --git a/src/arrayvec.rs b/src/arrayvec.rs index 92d1bfce..e67fbeea 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -707,8 +707,8 @@ impl ArrayVec { pub unsafe fn into_inner_unchecked(self) -> [T; CAP] { debug_assert_eq!(self.len(), self.capacity()); let self_ = ManuallyDrop::new(self); - let array = ptr::read(self_.as_ptr() as *const [T; CAP]); - array + + ptr::read(self_.as_ptr() as *const [T; CAP]) } /// Returns the ArrayVec, replacing the original with a new empty ArrayVec. @@ -721,7 +721,7 @@ impl ArrayVec { /// assert!(v.is_empty()); /// ``` pub fn take(&mut self) -> Self { - mem::replace(self, Self::new()) + std::mem::take(self) } /// Return a slice containing all elements of the vector. @@ -1143,7 +1143,7 @@ impl ArrayVec { let ptr = self.as_mut_ptr(); // WritebackGuard updates self.len on drop (both success and panic). - let mut guard = WritebackGuard { target: &mut self.len, len: len }; + let mut guard = WritebackGuard { target: &mut self.len, len }; // Take elements from the input iterator and write them into // the arrayvec, as long as there is capacity left. diff --git a/src/errors.rs b/src/errors.rs index fa96bc7c..c88751d4 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -14,7 +14,7 @@ impl CapacityError { /// Create a new `CapacityError` from `element`. pub const fn new(element: T) -> CapacityError { CapacityError { - element: element, + element, } } @@ -29,7 +29,7 @@ impl CapacityError { } } -const CAPERROR: &'static str = "insufficient capacity"; +const CAPERROR: &str = "insufficient capacity"; #[cfg(feature="std")] /// Requires `features="std"`.