From 021f134a3b87674be3567583c2dd04e763075f37 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 21 May 2026 19:25:00 +0800 Subject: Simplify path picking and accept Path references in checks --- mingling/src/parser/picker/path.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'mingling') 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 { fn pick(args: &mut crate::parser::Argument, flag: mingling_core::Flag) -> Option { let raw: Vec = args.pick_arguments(flag); - let paths: Vec = raw.into_iter().map(|s| PathBuf::from(s)).collect(); + let paths: Vec = raw.into_iter().map(PathBuf::from).collect(); Some(paths) } } @@ -107,7 +107,7 @@ fn check_path(path: impl Into, 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(()); }; -- cgit