Merge pull request #1283 from tmccombs/new-rust-version
Before adoption: this commit came in with the history the project adopted, so no landing records it.
A few changes to take advantage of the new MSRV
authored by Tavian Barnes · committed by GitHub · parents 3ac2e13, 31ac4a3 · Browse files · 7 files·+25 added−30 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
7 files+25 added−30 removed
- other:+25 added−30 removed
Provenance
- Commit
e4bca10- Tree
db76e80- Author
Tavian Barnes <tavianator@tavianator.com>- Committer
GitHub <noreply@github.com>- Parent 1
3ac2e13- Parent 2
31ac4a3
7 files changed+25 added−30 removed
modified:.github/workflows/CICD.yml+1 added-1 removed
1 name: CICD2 3 env:4- MIN_SUPPORTED_RUST_VERSION: "1.64.0"4+ MIN_SUPPORTED_RUST_VERSION: "1.67.0"5 CICD_INTERMEDIATES_DIR: "_cicd-intermediates"6 7 on:8 workflow_dispatch:355 unmodified linesmodified:src/exec/job.rs+4 added-4 removed
1-use std::sync::{Arc, Mutex};1+use std::sync::Mutex;2 3 use crossbeam_channel::Receiver;4 5 use crate::config::Config;8 unmodified lines14 /// generate a command with the supplied command template. The generated command will then15 /// be executed, and this process will continue until the receiver's sender has closed.16 pub fn job(17 rx: Receiver<WorkerResult>,18- cmd: Arc<CommandSet>,19- out_perm: Arc<Mutex<()>>,18+ cmd: &CommandSet,19+ out_perm: &Mutex<()>,20 config: &Config,21 ) -> ExitCode {22 // Output should be buffered when only running a single thread23 let buffer_output: bool = config.threads > 1;16 unmodified lines40 // Generate a command, execute it and store its exit code.41 results.push(cmd.execute(42 dir_entry.stripped_path(config),43 config.path_separator.as_deref(),44- Arc::clone(&out_perm),44+ out_perm,45 buffer_output,46 ))47 }48 // Returns error in case of any error.18 unmodified linesmodified:src/exec/mod.rs+3 added-3 removed
7 unmodified lines8 use std::io;9 use std::iter;10 use std::path::{Component, Path, PathBuf, Prefix};11 use std::process::Stdio;12-use std::sync::{Arc, Mutex};12+use std::sync::Mutex;13 14 use anyhow::{bail, Result};15 use argmax::Command;16 use once_cell::sync::Lazy;68 unmodified lines85 pub fn execute(86 &self,87 input: &Path,88 path_separator: Option<&str>,89- out_perm: Arc<Mutex<()>>,89+ out_perm: &Mutex<()>,90 buffer_output: bool,91 ) -> ExitCode {92 let commands = self93 .commands94 .iter()95 .map(|c| c.generate(input, path_separator));96- execute_commands(commands, &out_perm, buffer_output)96+ execute_commands(commands, out_perm, buffer_output)97 }98 99 pub fn execute_batch<I>(&self, paths: I, limit: usize, path_separator: Option<&str>) -> ExitCode100 where496 unmodified linesmodified:src/cli.rs+1 added-1 removed
693 unmodified lines694 695 pub fn max_results(&self) -> Option<usize> {696 self.max_results697 .filter(|&m| m > 0)698- .or_else(|| self.max_one_result.then(|| 1))698+ .or_else(|| self.max_one_result.then_some(1))699 }700 701 #[cfg(feature = "completions")]702 pub fn gen_completions(&self) -> anyhow::Result<Option<Shell>> {159 unmodified linesmodified:src/walk.rs+14 added-19 removed
345 unmodified lines346 if let Some(ref cmd) = config.command {347 if cmd.in_batch_mode() {348 exec::batch(rx, cmd, &config)349 } else {350- let out_perm = Arc::new(Mutex::new(()));350+ let out_perm = Mutex::new(());351 352- // Each spawned job will store it's thread handle in here.353- let mut handles = Vec::with_capacity(threads);354- for _ in 0..threads {355- let config = Arc::clone(&config);356- let rx = rx.clone();357- let cmd = Arc::clone(cmd);358- let out_perm = Arc::clone(&out_perm);352+ thread::scope(|scope| {353+ // Each spawned job will store it's thread handle in here.354+ let mut handles = Vec::with_capacity(threads);355+ for _ in 0..threads {356+ let rx = rx.clone();357 360- // Spawn a job thread that will listen for and execute inputs.361- let handle = thread::spawn(move || exec::job(rx, cmd, out_perm, &config));358+ // Spawn a job thread that will listen for and execute inputs.359+ let handle = scope.spawn(|| exec::job(rx, cmd, &out_perm, &config));360 363- // Push the handle of the spawned thread into the vector for later joining.364- handles.push(handle);365- }366-367- let exit_codes = handles368- .into_iter()369- .map(|handle| handle.join().unwrap())370- .collect::<Vec<_>>();371- merge_exitcodes(exit_codes)361+ // Push the handle of the spawned thread into the vector for later joining.362+ handles.push(handle);363+ }364+ let exit_codes = handles.into_iter().map(|handle| handle.join().unwrap());365+ merge_exitcodes(exit_codes)366+ })367 }368 } else {369 let stdout = io::stdout();370 let stdout = stdout.lock();183 unmodified linesmodified:Cargo.toml+1 added-1 removed
16 unmodified lines1718192021212223242571 unmodified lines16 unmodified linesreadme = "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"
71 unmodified linesmodified:clippy.toml+1 added-1 removed
11msrv = "1.64.0"msrv = "1.67.0"