Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A few changes to take advantage of the new MSRV #1283

Merged
merged 4 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: CICD

env:
MIN_SUPPORTED_RUST_VERSION: "1.64.0"
MIN_SUPPORTED_RUST_VERSION: "1.67.0"
CICD_INTERMEDIATES_DIR: "_cicd-intermediates"

on:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ readme = "README.md"
repository = "https://github.com/sharkdp/fd"
version = "8.7.0"
edition= "2021"
rust-version = "1.64.0"
rust-version = "1.67.0"

[badges.appveyor]
repository = "sharkdp/fd"
Expand Down
2 changes: 1 addition & 1 deletion clippy.toml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
msrv = "1.64.0"
msrv = "1.67.0"
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ impl Opts {
pub fn max_results(&self) -> Option<usize> {
self.max_results
.filter(|&m| m > 0)
.or_else(|| self.max_one_result.then(|| 1))
.or_else(|| self.max_one_result.then_some(1))
}

#[cfg(feature = "completions")]
Expand Down
8 changes: 4 additions & 4 deletions src/exec/job.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::sync::{Arc, Mutex};
use std::sync::Mutex;

use crossbeam_channel::Receiver;

Expand All @@ -15,8 +15,8 @@ use super::CommandSet;
/// be executed, and this process will continue until the receiver's sender has closed.
pub fn job(
rx: Receiver<WorkerResult>,
cmd: Arc<CommandSet>,
out_perm: Arc<Mutex<()>>,
cmd: &CommandSet,
out_perm: &Mutex<()>,
config: &Config,
) -> ExitCode {
// Output should be buffered when only running a single thread
Expand All @@ -41,7 +41,7 @@ pub fn job(
results.push(cmd.execute(
dir_entry.stripped_path(config),
config.path_separator.as_deref(),
Arc::clone(&out_perm),
out_perm,
buffer_output,
))
}
Expand Down
6 changes: 3 additions & 3 deletions src/exec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::io;
use std::iter;
use std::path::{Component, Path, PathBuf, Prefix};
use std::process::Stdio;
use std::sync::{Arc, Mutex};
use std::sync::Mutex;

use anyhow::{bail, Result};
use argmax::Command;
Expand Down Expand Up @@ -86,14 +86,14 @@ impl CommandSet {
&self,
input: &Path,
path_separator: Option<&str>,
out_perm: Arc<Mutex<()>>,
out_perm: &Mutex<()>,
buffer_output: bool,
) -> ExitCode {
let commands = self
.commands
.iter()
.map(|c| c.generate(input, path_separator));
execute_commands(commands, &out_perm, buffer_output)
execute_commands(commands, out_perm, buffer_output)
}

pub fn execute_batch<I>(&self, paths: I, limit: usize, path_separator: Option<&str>) -> ExitCode
Expand Down
33 changes: 14 additions & 19 deletions src/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,28 +347,23 @@ fn spawn_receiver(
if cmd.in_batch_mode() {
exec::batch(rx, cmd, &config)
} else {
let out_perm = Arc::new(Mutex::new(()));
let out_perm = Mutex::new(());

// Each spawned job will store it's thread handle in here.
let mut handles = Vec::with_capacity(threads);
for _ in 0..threads {
let config = Arc::clone(&config);
let rx = rx.clone();
let cmd = Arc::clone(cmd);
let out_perm = Arc::clone(&out_perm);
thread::scope(|scope| {
// Each spawned job will store it's thread handle in here.
let mut handles = Vec::with_capacity(threads);
for _ in 0..threads {
let rx = rx.clone();

// Spawn a job thread that will listen for and execute inputs.
let handle = thread::spawn(move || exec::job(rx, cmd, out_perm, &config));
// Spawn a job thread that will listen for and execute inputs.
let handle = scope.spawn(|| exec::job(rx, cmd, &out_perm, &config));

// Push the handle of the spawned thread into the vector for later joining.
handles.push(handle);
}

let exit_codes = handles
.into_iter()
.map(|handle| handle.join().unwrap())
.collect::<Vec<_>>();
merge_exitcodes(exit_codes)
// Push the handle of the spawned thread into the vector for later joining.
handles.push(handle);
}
let exit_codes = handles.into_iter().map(|handle| handle.join().unwrap());
merge_exitcodes(exit_codes)
})
}
} else {
let stdout = io::stdout();
Expand Down