diff --git a/src/grm/main.rs b/src/grm/main.rs index 4b293dc..3d02872 100644 --- a/src/grm/main.rs +++ b/src/grm/main.rs @@ -199,7 +199,8 @@ fn main() { } }; - let (found_repos, warnings) = match find_in_tree(&path, &args.exclude) { + let (found_repos, warnings) = match find_in_tree(&path, args.exclude.as_deref()) + { Ok((repos, warnings)) => (repos, warnings), Err(error) => { print_error(&error); diff --git a/src/lib.rs b/src/lib.rs index 3cd48f2..49fed1c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -21,15 +21,14 @@ pub mod worktree; #[allow(clippy::type_complexity)] fn find_repos( root: &Path, - exclusion_pattern: &Option, + exclusion_pattern: Option<&str>, ) -> Result, Vec, bool)>, String> { let mut repos: Vec = Vec::new(); let mut repo_in_root = false; let mut warnings = Vec::new(); - let exlusion_regex: regex::Regex = - regex::Regex::new(&exclusion_pattern.clone().unwrap_or(r"^$".to_string())) - .unwrap_or_else(|_| regex::Regex::new(r"^$").unwrap()); + let exlusion_regex: regex::Regex = regex::Regex::new(&exclusion_pattern.unwrap_or(r"^$")) + .unwrap_or_else(|_| regex::Regex::new(r"^$").unwrap()); for path in tree::find_repo_paths(root)? { if exclusion_pattern.is_some() && exlusion_regex.is_match(&path::path_as_string(&path)) { warnings.push(format!("[skipped] {}", &path::path_as_string(&path))); @@ -143,7 +142,7 @@ fn find_repos( pub fn find_in_tree( path: &Path, - exclusion_pattern: &Option, + exclusion_pattern: Option<&str>, ) -> Result<(tree::Tree, Vec), String> { let mut warnings = Vec::new();