Skip to content
Myr

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

7 files+25 added−30 removed

modified:.github/workflows/CICD.yml+1 added-1 removed
1name: CICD23env:4 MIN_SUPPORTED_RUST_VERSION: "1.64.0"4 MIN_SUPPORTED_RUST_VERSION: "1.67.0"5 CICD_INTERMEDIATES_DIR: "_cicd-intermediates"67on:8 workflow_dispatch:
355 unmodified lines
modified:src/exec/job.rs+4 added-4 removed
1use std::sync::{Arc, Mutex};1use std::sync::Mutex;23use crossbeam_channel::Receiver;45use crate::config::Config;
8 unmodified lines
14/// 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.16pub 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 lines
40 // 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 lines
modified:src/exec/mod.rs+3 added-3 removed
7 unmodified lines
8use std::io;9use std::iter;10use std::path::{Component, Path, PathBuf, Prefix};11use std::process::Stdio;12use std::sync::{Arc, Mutex};12use std::sync::Mutex;1314use anyhow::{bail, Result};15use argmax::Command;16use once_cell::sync::Lazy;
68 unmodified lines
85 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 }9899 pub fn execute_batch<I>(&self, paths: I, limit: usize, path_separator: Option<&str>) -> ExitCode100 where
496 unmodified lines
modified:src/cli.rs+1 added-1 removed
693 unmodified lines
694695 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 }700701 #[cfg(feature = "completions")]702 pub fn gen_completions(&self) -> anyhow::Result<Option<Shell>> {
159 unmodified lines
modified:src/walk.rs+14 added-19 removed
345 unmodified lines
346 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(());351352 // 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();357360 // 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));360363 // Push the handle of the spawned thread into the vector for later joining.364 handles.push(handle);365 }366367 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 lines
modified:Cargo.toml+1 added-1 removed
modified:clippy.toml+1 added-1 removed