diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-20 22:21:56 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-20 22:21:56 +0800 |
| commit | ab6be7968b25afb57fc428695693484ad8576718 (patch) | |
| tree | e4af27964f195a18a678844dbe71c0aaa182b5dc /utils/src/legacy/globber.rs | |
| parent | 6b22f7b7694fce530f84ba94c65c057450cca626 (diff) | |
Refactor code to use modern Rust idioms and fix clippy lints
Diffstat (limited to 'utils/src/legacy/globber.rs')
| -rw-r--r-- | utils/src/legacy/globber.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/utils/src/legacy/globber.rs b/utils/src/legacy/globber.rs index 4d722db..b6a3032 100644 --- a/utils/src/legacy/globber.rs +++ b/utils/src/legacy/globber.rs @@ -69,9 +69,7 @@ impl Globber { } }; - let pattern = if pattern.is_empty() { - "*".to_string() - } else if pattern == "." { + let pattern = if pattern.is_empty() || pattern == "." { "*".to_string() } else if pattern.ends_with(SPLIT_STR) { format!("{}*", pattern) @@ -182,7 +180,7 @@ impl<T: AsRef<str>> From<T> for Globber { } } -#[derive(Debug, Clone, Hash)] +#[derive(Debug, Clone)] pub enum GlobItem { File(String), Directory(String), @@ -207,6 +205,21 @@ impl std::fmt::Display for GlobItem { } } +impl std::hash::Hash for GlobItem { + fn hash<H: std::hash::Hasher>(&self, state: &mut H) { + match self { + GlobItem::File(name) => { + state.write_u8(0); + name.hash(state); + } + GlobItem::Directory(name) => { + state.write_u8(1); + name.hash(state); + } + } + } +} + impl Eq for GlobItem {} pub mod constants { |
