mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
Eliding some lifetimes
This commit is contained in:
parent
f51a5c8727
commit
d1734b54cb
17
src/cli.rs
17
src/cli.rs
@ -52,10 +52,7 @@ pub struct ParsedArgs {
|
|||||||
/// check_for_typo checks if the first argument is
|
/// check_for_typo checks if the first argument is
|
||||||
/// a typo for the compress subcommand.
|
/// a typo for the compress subcommand.
|
||||||
/// Returns true if the arg is probably a typo or false otherwise.
|
/// Returns true if the arg is probably a typo or false otherwise.
|
||||||
fn is_typo<'a, P>(path: P) -> bool
|
fn is_typo(path: impl AsRef<Path>) -> bool {
|
||||||
where
|
|
||||||
P: AsRef<Path> + 'a,
|
|
||||||
{
|
|
||||||
if path.as_ref().exists() {
|
if path.as_ref().exists() {
|
||||||
// If the file exists then we won't check for a typo
|
// If the file exists then we won't check for a typo
|
||||||
return false;
|
return false;
|
||||||
@ -66,10 +63,7 @@ where
|
|||||||
normalized_damerau_levenshtein("compress", &path) > 0.625
|
normalized_damerau_levenshtein("compress", &path) > 0.625
|
||||||
}
|
}
|
||||||
|
|
||||||
fn canonicalize<'a, P>(path: P) -> crate::Result<PathBuf>
|
fn canonicalize(path: impl AsRef<Path>) -> crate::Result<PathBuf> {
|
||||||
where
|
|
||||||
P: AsRef<Path> + 'a,
|
|
||||||
{
|
|
||||||
match std::fs::canonicalize(&path.as_ref()) {
|
match std::fs::canonicalize(&path.as_ref()) {
|
||||||
Ok(abs_path) => Ok(abs_path),
|
Ok(abs_path) => Ok(abs_path),
|
||||||
Err(io_err) => {
|
Err(io_err) => {
|
||||||
@ -82,11 +76,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn canonicalize_files<'a, P>(files: &[P]) -> crate::Result<Vec<PathBuf>>
|
fn canonicalize_files(files: &[impl AsRef<Path>]) -> crate::Result<Vec<PathBuf>> {
|
||||||
where
|
files.iter().map(canonicalize).collect()
|
||||||
P: AsRef<Path> + 'a,
|
|
||||||
{
|
|
||||||
files.into_iter().map(canonicalize).collect()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn parse_args_from(mut args: Vec<OsString>) -> crate::Result<ParsedArgs> {
|
pub fn parse_args_from(mut args: Vec<OsString>) -> crate::Result<ParsedArgs> {
|
||||||
|
@ -23,10 +23,7 @@ macro_rules! debug {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ensure_exists<'a, P>(path: P) -> crate::Result<()>
|
pub fn ensure_exists(path: impl AsRef<Path>) -> crate::Result<()> {
|
||||||
where
|
|
||||||
P: AsRef<Path> + 'a,
|
|
||||||
{
|
|
||||||
let exists = path.as_ref().exists();
|
let exists = path.as_ref().exists();
|
||||||
if !exists {
|
if !exists {
|
||||||
return Err(crate::Error::FileNotFound(PathBuf::from(path.as_ref())));
|
return Err(crate::Error::FileNotFound(PathBuf::from(path.as_ref())));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user