diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-05-21 19:25:00 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-05-21 19:25:00 +0800 |
| commit | 021f134a3b87674be3567583c2dd04e763075f37 (patch) | |
| tree | 02f65e7f3ec2198f173b97ae5c44a745ac60075c /mingling/src | |
| parent | 2213d332782764ab19e20c867bafa75a8aab0b65 (diff) | |
Simplify path picking and accept Path references in checks
Diffstat (limited to 'mingling/src')
| -rw-r--r-- | mingling/src/parser/picker/path.rs | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/mingling/src/parser/picker/path.rs b/mingling/src/parser/picker/path.rs index 589531f..c97250f 100644 --- a/mingling/src/parser/picker/path.rs +++ b/mingling/src/parser/picker/path.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use crate::parser::Pickable; @@ -10,7 +10,7 @@ impl Pickable for Vec<PathBuf> { fn pick(args: &mut crate::parser::Argument, flag: mingling_core::Flag) -> Option<Self::Output> { let raw: Vec<String> = args.pick_arguments(flag); - let paths: Vec<PathBuf> = raw.into_iter().map(|s| PathBuf::from(s)).collect(); + let paths: Vec<PathBuf> = raw.into_iter().map(PathBuf::from).collect(); Some(paths) } } @@ -107,7 +107,7 @@ fn check_path(path: impl Into<PathBuf>, rule: &PathCheckRule) -> Result<(), ()> Ok(()) } -fn check_exist(path: &PathBuf, rule: &PathCheckRule) -> Result<(), ()> { +fn check_exist(path: &Path, rule: &PathCheckRule) -> Result<(), ()> { let Some(exist_check) = &rule.exist_check else { return Ok(()); }; @@ -118,7 +118,7 @@ fn check_exist(path: &PathBuf, rule: &PathCheckRule) -> Result<(), ()> { } } -fn check_type(path: &PathBuf, rule: &PathCheckRule) -> Result<(), ()> { +fn check_type(path: &Path, rule: &PathCheckRule) -> Result<(), ()> { let Some(type_check) = &rule.type_check else { return Ok(()); }; |
