Skip to content

Commit

Permalink
use default init
Browse files Browse the repository at this point in the history
  • Loading branch information
ms-jpq committed Jun 9, 2022
1 parent f1625f2 commit d96da46
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 28 deletions.
30 changes: 15 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["[email protected]"]
description = "Space Age seD | https://github.com/ms-jpq/sad"
edition = "2021"
name = "sad"
version = "0.4.21"
version = "0.4.22"


[build-dependencies]
Expand Down
4 changes: 2 additions & 2 deletions src/argparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::new())),
None => Some((p, Default::default())),
},
_ => None,
}
Expand All @@ -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::new()),
Some("never") => (None, Default::default()),
Some(val) => {
let mut sh = split(val)
.unwrap_or_else(|| vec![val.to_owned()])
Expand Down
2 changes: 1 addition & 1 deletion src/displace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub async fn displace(opts: &Arc<Options>, payload: Payload) -> Result<OsString,
let after = spawn_blocking(move || o.engine.replace(&b)).await?;

if *before == after {
Ok(OsString::new())
Ok(Default::default())
} else {
let print = match (&opts.action, payload) {
(Action::Preview, Payload::Entire(_)) => {
Expand Down
4 changes: 2 additions & 2 deletions src/fs_pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ pub async fn slurp(path: &Path) -> Result<Slurpee, Fail> {
.map_err(|e| Fail::IO(path.to_owned(), e.kind()))?;

let content = if meta.is_file() {
let mut s = String::new();
let mut s = Default::default();
match fd.read_to_string(&mut s).await {
Ok(_) => s,
Err(err) if err.kind() == ErrorKind::InvalidData => s,
Err(err) => return Err(Fail::IO(path.to_owned(), err.kind())),
}
} else {
String::new()
Default::default()
};

Ok(Slurpee { meta, content })
Expand Down
8 changes: 4 additions & 4 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub enum Payload {
struct DiffLine(PathBuf, DiffRange);

fn p_line(line: &str) -> Result<DiffLine, Fail> {
let f = Fail::ArgumentError(String::new());
let f = Fail::ArgumentError(Default::default());
let preg = "\n\n\n\n@@ -(\\d+),(\\d+) \\+(\\d+),(\\d+) @@$";
let re = Regex::new(preg).map_err(Fail::RegexError)?;
let captures = re.captures(line).ok_or_else(|| f.clone())?;
Expand Down Expand Up @@ -76,10 +76,10 @@ async fn read_patches(path_file: &Path) -> Result<HashMap<PathBuf, HashSet<DiffR
.await
.map_err(|e| Fail::IO(path_file.to_owned(), e.kind()))?;
let mut reader = BufReader::new(fd);
let mut acc = HashMap::<PathBuf, HashSet<DiffRange>>::new();
let mut acc = HashMap::<_, HashSet<_>>::new();

loop {
let mut buf = Vec::new();
let mut buf = Default::default();
let n = reader
.read_until(b'\0', &mut buf)
.await
Expand Down Expand Up @@ -163,7 +163,7 @@ fn stream_stdin(abort: &Arc<Abort>, use_nul: bool) -> (JoinHandle<()>, Receiver<
let mut seen = HashSet::new();

loop {
let mut buf = Vec::new();
let mut buf = Default::default();
let f1 = abort.notified();
let f2 = reader.read_until(delim, &mut buf);

Expand Down
2 changes: 1 addition & 1 deletion src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub struct Abort {
impl Abort {
pub fn new() -> Arc<Self> {
Arc::new(Self {
errors: Mutex::new(Vec::new()),
errors: Mutex::new(Default::default()),
rx: Notify::new(),
})
}
Expand Down
3 changes: 1 addition & 2 deletions src/udiff_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ mod udiff_spec {
use regex::Regex;
use std::{
collections::HashSet,
ffi::OsStr,
fs::{read_dir, read_to_string},
path::PathBuf,
};
Expand Down Expand Up @@ -101,7 +100,7 @@ mod udiff_spec {
}
})
.collect::<Vec<_>>();
let imp = udiff(None, unified, &OsStr::new(""), &before, &after)
let imp = udiff(None, unified, Default::default(), &before, &after)
.to_string_lossy()
.split_inclusive("\n")
.skip(3)
Expand Down

0 comments on commit d96da46

Please sign in to comment.