diff options
-rw-r--r-- | src/argparse.rs | 4 | ||||
-rw-r--r-- | src/displace.rs | 2 | ||||
-rw-r--r-- | src/fs_pipe.rs | 4 | ||||
-rw-r--r-- | src/input.rs | 25 |
4 files changed, 18 insertions, 17 deletions
diff --git a/src/argparse.rs b/src/argparse.rs index ca850f2..7bde102 100644 --- a/src/argparse.rs +++ b/src/argparse.rs @@ -200,7 +200,7 @@ fn p_fzf(fzf: &Option<String>) -> Option<(PathBuf, Vec<String>)> { (Ok(p), true, true) => match fzf.as_deref() { Some("never") => None, Some(val) => Some((p, split(val).unwrap_or_default())), - None => Some((p, Vec::default())), + None => Some((p, Vec::new())), }, _ => None, } @@ -210,7 +210,7 @@ fn p_pager(pager: &Option<String>) -> Option<SubprocCommand> { let norm = || which("delta").or_else(|_| which("diff-so-fancy")).ok(); let (prog, arguments) = match pager.as_deref() { - Some("never") => (None, Vec::default()), + Some("never") => (None, Vec::new()), Some(val) => { let mut sh = split(val) .unwrap_or_else(|| vec![val.to_owned()]) diff --git a/src/displace.rs b/src/displace.rs index 4c19349..d354e84 100644 --- a/src/displace.rs +++ b/src/displace.rs @@ -42,7 +42,7 @@ pub async fn displace(opts: &Arc<Options>, input: LineIn) -> Result<OsString, Di let after = opts.engine.replace(&before); if *before == after { - Ok(OsString::default()) + Ok(OsString::new()) } else { let print = match (&opts.action, input) { (Action::Preview, LineIn::Entire(_)) => udiff(None, opts.unified, &name, &before, &after), diff --git a/src/fs_pipe.rs b/src/fs_pipe.rs index 5972275..96812b7 100644 --- a/src/fs_pipe.rs +++ b/src/fs_pipe.rs @@ -24,14 +24,14 @@ pub async fn slurp(path: &Path) -> Result<Slurpee, Die> { .map_err(|e| Die::IO(path.to_owned(), e.kind()))?; let content = if meta.is_file() { - let mut s = String::default(); + let mut s = String::new(); match fd.read_to_string(&mut s).await { Ok(_) => s, Err(err) if err.kind() == ErrorKind::InvalidData => s, Err(err) => return Err(Die::IO(path.to_owned(), err.kind())), } } else { - String::default() + String::new() }; Ok(Slurpee { meta, content }) diff --git a/src/input.rs b/src/input.rs index 69e9f7c..7bcd858 100644 --- a/src/input.rs +++ b/src/input.rs @@ -31,35 +31,36 @@ pub enum LineIn { struct DiffLine(PathBuf, DiffRange); fn p_line(line: &str) -> Result<DiffLine, Die> { - let f = Die::ArgumentError(String::default()); + let f = || Die::ArgumentError(String::new()); + let ff = |_| f(); let preg = "\n\n\n\n@@ -(\\d+),(\\d+) \\+(\\d+),(\\d+) @@$"; let re = Regex::new(preg).map_err(Die::RegexError)?; - let captures = re.captures(line).ok_or_else(|| f.clone())?; + let captures = re.captures(line).ok_or_else(f)?; let before_start = captures .get(1) - .ok_or_else(|| f.clone())? + .ok_or_else(f)? .as_str() .parse::<usize>() - .map_err(|_| f.clone())?; + .map_err(ff)?; let before_inc = captures .get(2) - .ok_or_else(|| f.clone())? + .ok_or_else(f)? .as_str() .parse::<usize>() - .map_err(|_| f.clone())?; + .map_err(ff)?; let after_start = captures .get(3) - .ok_or_else(|| f.clone())? + .ok_or_else(f)? .as_str() .parse::<usize>() - .map_err(|_| f.clone())?; + .map_err(ff)?; let after_inc = captures .get(4) - .ok_or_else(|| f.clone())? + .ok_or_else(f)? .as_str() .parse::<usize>() - .map_err(|_| f.clone())?; + .map_err(ff)?; let range = DiffRange { before: (before_start - 1, before_inc), @@ -85,7 +86,7 @@ async fn stream_patch(patches: &Path) -> impl Stream<Item = Result<LineIn, Die>> let stream = try_unfold( (reader, patches, PathBuf::new(), acc), move |mut s| async move { - let mut buf = Vec::default(); + let mut buf = Vec::new(); match s.0.read_until(b'\0', &mut buf).await { Err(err) => Err(Die::IO(s.1.clone(), err.kind())), Ok(0) if s.3.is_empty() => Ok(None), @@ -153,7 +154,7 @@ fn stream_stdin(use_nul: bool) -> impl Stream<Item = Result<LineIn, Die>> { let seen = HashSet::new(); let stream = try_unfold((reader, seen), move |mut s| async move { - let mut buf = Vec::default(); + let mut buf = Vec::new(); match s.0.read_until(delim, &mut buf).await { Err(e) => Err(Die::IO(PathBuf::from("/dev/stdin"), e.kind())), Ok(0) => Ok(None), |