diff --git a/lib/etc/libimagutil/src/cli_validators.rs b/lib/etc/libimagutil/src/cli_validators.rs index 49cee6c1..e2e9c8a5 100644 --- a/lib/etc/libimagutil/src/cli_validators.rs +++ b/lib/etc/libimagutil/src/cli_validators.rs @@ -23,27 +23,27 @@ use std::path::PathBuf; use boolinator::Boolinator; -pub fn is_existing_path(s: String) -> Result<(), String> { - PathBuf::from(s.clone()).exists().as_result((), format!("Not a File or Directory: {}", s)) +pub fn is_existing_path>(s: A) -> Result<(), String> { + PathBuf::from(s.as_ref()).exists().as_result((), format!("Not a File or Directory: {}", s.as_ref())) } -pub fn is_file(s: String) -> Result<(), String> { - PathBuf::from(s.clone()).is_file().as_result((), format!("Not a File: {}", s)) +pub fn is_file>(s: A) -> Result<(), String> { + PathBuf::from(s.as_ref()).is_file().as_result((), format!("Not a File: {}", s.as_ref())) } -pub fn is_directory(s: String) -> Result<(), String> { - PathBuf::from(s.clone()).is_dir().as_result((), format!("Not a Directory: {}", s)) +pub fn is_directory>(s: A) -> Result<(), String> { + PathBuf::from(s.as_ref()).is_dir().as_result((), format!("Not a Directory: {}", s.as_ref())) } -pub fn is_integer(s: String) -> Result<(), String> { +pub fn is_integer>(s: A) -> Result<(), String> { use std::str::FromStr; - let i : Result = FromStr::from_str(&s); - i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s)) + let i : Result = FromStr::from_str(s.as_ref()); + i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s.as_ref())) } -pub fn is_url(s: String) -> Result<(), String> { +pub fn is_url>(s: A) -> Result<(), String> { use url::Url; - Url::parse(&s).map(|_| ()).map_err(|_| format!("Not a URL: {}", s)) + Url::parse(s.as_ref()).map(|_| ()).map_err(|_| format!("Not a URL: {}", s.as_ref())) }