diff --git a/src/cmd/import.rs b/src/cmd/import.rs index ae667d4..182a25f 100644 --- a/src/cmd/import.rs +++ b/src/cmd/import.rs @@ -31,17 +31,15 @@ fn import_autojump(db: &mut Database, buffer: &str) -> Result<()> { if line.is_empty() { continue; } - let mut split = line.splitn(2, '\t'); + let (rank, path) = + line.split_once('\t').with_context(|| format!("invalid entry: {line}"))?; - let rank = split.next().with_context(|| format!("invalid entry: {line}"))?; let mut rank = rank.parse::().with_context(|| format!("invalid rank: {rank}"))?; // Normalize the rank using a sigmoid function. Don't import actual ranks from // autojump, since its scoring algorithm is very different and might // take a while to get normalized. rank = sigmoid(rank); - let path = split.next().with_context(|| format!("invalid entry: {line}"))?; - db.add_unchecked(path, rank, 0); } diff --git a/src/shell.rs b/src/shell.rs index 6237f76..a50c184 100644 --- a/src/shell.rs +++ b/src/shell.rs @@ -96,13 +96,11 @@ mod tests { #[apply(opts)] fn elvish_elvish(cmd: Option<&str>, hook: InitHook, echo: bool, resolve_symlinks: bool) { let opts = Opts { cmd, hook, echo, resolve_symlinks }; - let mut source = String::new(); + let mut source = String::default(); // Filter out lines using edit:*, since those functions are only available in // the interactive editor. - for line in - Elvish(&opts).render().unwrap().split('\n').filter(|line| !line.contains("edit:")) - { + for line in Elvish(&opts).render().unwrap().lines().filter(|line| !line.contains("edit:")) { source.push_str(line); source.push('\n'); } diff --git a/src/util.rs b/src/util.rs index 168c3af..47e7e93 100644 --- a/src/util.rs +++ b/src/util.rs @@ -135,7 +135,7 @@ impl FzfChild { mem::drop(self.0.stdin.take()); let mut stdout = self.0.stdout.take().unwrap(); - let mut output = String::new(); + let mut output = String::default(); stdout.read_to_string(&mut output).context("failed to read from fzf")?; let status = self.0.wait().context("wait failed on fzf")?;