From 02e07a18fcb3af9319c271f6e41d5b7785e2e436 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 10 Aug 2026 16:52:19 +0800 Subject: style: satisfy clippy pedantic and nursery lints --- arg_picker/src/value/paths.rs | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'arg_picker/src/value/paths.rs') diff --git a/arg_picker/src/value/paths.rs b/arg_picker/src/value/paths.rs index 403d6cc..d64a09f 100644 --- a/arg_picker/src/value/paths.rs +++ b/arg_picker/src/value/paths.rs @@ -117,7 +117,7 @@ pub struct NoPath { path: PathBuf, } -/// Implements common trait impls (From, AsRef, Deref, DerefMut) for a path wrapper type. +/// Implements common trait impls (`From`, `AsRef`, `Deref`, `DerefMut`) for a path wrapper type. macro_rules! impl_path_traits { ($type:ident) => { impl From for $type { @@ -227,12 +227,14 @@ impl DerefMut for RecursiveFiles { impl RecursiveFiles { /// Returns the number of file paths. - pub fn len(&self) -> usize { + #[must_use] + pub const fn len(&self) -> usize { self.paths.len() } /// Returns `true` if there are no file paths. - pub fn is_empty(&self) -> bool { + #[must_use] + pub const fn is_empty(&self) -> bool { self.paths.is_empty() } @@ -242,8 +244,17 @@ impl RecursiveFiles { } } -impl From> for RecursiveFiles { - fn from(value: Vec) -> Self { +impl<'a> IntoIterator for &'a RecursiveFiles { + type Item = &'a PathBuf; + type IntoIter = std::slice::Iter<'a, PathBuf>; + + fn into_iter(self) -> Self::IntoIter { + self.iter() + } +} + +impl From> for RecursiveFiles { + fn from(value: Vec) -> Self { Self { paths: value.into_iter().flat_map(|r| r.paths).collect(), } -- cgit