chore: format code via rustfmt

This commit is contained in:
psinghal20 2018-10-01 02:26:32 +05:30 committed by David Peter
parent 2ebef2d46f
commit 6407dc4eb4
2 changed files with 16 additions and 12 deletions

View file

@ -6,17 +6,21 @@
// notice may not be copied, modified, or distributed except
// according to those terms.
use super::CommandTemplate;
use internal::error;
use std::path::PathBuf;
use std::sync::mpsc::Receiver;
use std::sync::{Arc, Mutex};
use::walk::WorkerResult;
use::internal::error;
use super::CommandTemplate;
use walk::WorkerResult;
/// An event loop that listens for inputs from the `rx` receiver. Each received input will
/// generate a command with the supplied command template. The generated command will then
/// be executed, and this process will continue until the receiver's sender has closed.
pub fn job(rx: Arc<Mutex<Receiver<WorkerResult>>>, cmd: Arc<CommandTemplate>, out_perm: Arc<Mutex<()>>) {
pub fn job(
rx: Arc<Mutex<Receiver<WorkerResult>>>,
cmd: Arc<CommandTemplate>,
out_perm: Arc<Mutex<()>>,
) {
loop {
// Create a lock on the shared receiver for this thread.
let lock = rx.lock().unwrap();
@ -24,12 +28,10 @@ pub fn job(rx: Arc<Mutex<Receiver<WorkerResult>>>, cmd: Arc<CommandTemplate>, ou
// Obtain the next path from the receiver, else if the channel
// has closed, exit from the loop
let value: PathBuf = match lock.recv() {
Ok(value) => {
match value {
WorkerResult::Entry(val) => val,
WorkerResult::Error(err) => {
error(&format!("{}", err));
}
Ok(value) => match value {
WorkerResult::Entry(val) => val,
WorkerResult::Error(err) => {
error(&format!("{}", err));
}
},
Err(_) => break,

View file

@ -39,7 +39,7 @@ enum ReceiverMode {
/// The Worker threads can result in a valid entry having PathBuf or an error.
pub enum WorkerResult {
Entry(PathBuf),
Error(ignore::Error)
Error(ignore::Error),
}
/// Recursively scan the given search path for files / pathnames matching the pattern.
@ -300,7 +300,9 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<FdOptions>) {
if let Some(search_str) = search_str_o {
if pattern.is_match(&*search_str) {
// TODO: take care of the unwrap call
tx_thread.send(WorkerResult::Entry(entry_path.to_owned())).unwrap()
tx_thread
.send(WorkerResult::Entry(entry_path.to_owned()))
.unwrap()
}
}