diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-10 16:52:19 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-10 16:52:19 +0800 |
| commit | 02e07a18fcb3af9319c271f6e41d5b7785e2e436 (patch) | |
| tree | ff76916c254e87a7aadc5cb4dfd2134eaf4f03fc /arg_picker/src/value/paths.rs | |
| parent | 03b487f0f93ac32835149d4c1a0fb420341134f8 (diff) | |
style: satisfy clippy pedantic and nursery lints
Diffstat (limited to 'arg_picker/src/value/paths.rs')
| -rw-r--r-- | arg_picker/src/value/paths.rs | 21 |
1 files changed, 16 insertions, 5 deletions
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<PathBuf> 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<Vec<RecursiveFiles>> for RecursiveFiles { - fn from(value: Vec<RecursiveFiles>) -> 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<Vec<Self>> for RecursiveFiles { + fn from(value: Vec<Self>) -> Self { Self { paths: value.into_iter().flat_map(|r| r.paths).collect(), } |
