1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-04 15:07:47 +00:00

refactor/polish ~ fix cargo clippy complaints (remove unit value as function arg)

This commit is contained in:
Roy Ivy III 2019-12-28 23:11:44 -06:00
parent 8ec50b72d1
commit 7cc3571657
5 changed files with 13 additions and 10 deletions

View file

@ -946,7 +946,7 @@ impl OverwriteMode {
fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResult<()> { fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResult<()> {
let context = &*format!("'{}' -> '{}'", source.display().to_string(), dest.display()); let context = &*format!("'{}' -> '{}'", source.display().to_string(), dest.display());
Ok(match *attribute { match *attribute {
#[cfg(unix)] #[cfg(unix)]
Attribute::Mode => { Attribute::Mode => {
let mode = fs::metadata(source).context(context)?.permissions().mode(); let mode = fs::metadata(source).context(context)?.permissions().mode();
@ -982,7 +982,8 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu
return Err("XAttrs are only supported on unix.".to_string().into()); return Err("XAttrs are only supported on unix.".to_string().into());
} }
} }
}) };
Ok(())
} }
#[cfg(not(windows))] #[cfg(not(windows))]

View file

@ -298,17 +298,18 @@ fn push_token_to_either_stack(
op_stack: &mut TokenStack, op_stack: &mut TokenStack,
) -> Result<(), String> { ) -> Result<(), String> {
let result = match *token { let result = match *token {
Token::Value { .. } => Ok(out_stack.push((token_idx, token.clone()))), Token::Value { .. } => { out_stack.push((token_idx, token.clone())); Ok(()) },
Token::InfixOp { .. } => if op_stack.is_empty() { Token::InfixOp { .. } => if op_stack.is_empty() {
Ok(op_stack.push((token_idx, token.clone()))) op_stack.push((token_idx, token.clone()));
Ok(())
} else { } else {
push_op_to_stack(token_idx, token, out_stack, op_stack) push_op_to_stack(token_idx, token, out_stack, op_stack)
}, },
Token::PrefixOp { .. } => Ok(op_stack.push((token_idx, token.clone()))), Token::PrefixOp { .. } => { op_stack.push((token_idx, token.clone())); Ok(()) },
Token::ParOpen => Ok(op_stack.push((token_idx, token.clone()))), Token::ParOpen => { op_stack.push((token_idx, token.clone())); Ok(()) },
Token::ParClose => move_till_match_paren(out_stack, op_stack), Token::ParClose => move_till_match_paren(out_stack, op_stack),
}; };
@ -349,7 +350,7 @@ fn push_op_to_stack(
{ {
loop { loop {
match op_stack.last() { match op_stack.last() {
None => return Ok(op_stack.push((token_idx, token.clone()))), None => { op_stack.push((token_idx, token.clone())); return Ok(()) },
Some(&(_, Token::ParOpen)) => { Some(&(_, Token::ParOpen)) => {
op_stack.push((token_idx, token.clone())); op_stack.push((token_idx, token.clone()));

View file

@ -154,7 +154,7 @@ fn print_factors(num: u64) {
} }
fn print_factors_str(num_str: &str) { fn print_factors_str(num_str: &str) {
if let Err(e) = num_str.parse::<u64>().and_then(|x| Ok(print_factors(x))) { if let Err(e) = num_str.parse::<u64>().and_then(|x| { print_factors(x); Ok(()) }) {
show_warning!("{}: {}", num_str, e); show_warning!("{}: {}", num_str, e);
} }
} }

View file

@ -276,7 +276,8 @@ fn handle_stdin(options: NumfmtOptions) -> Result<()> {
for l in lines { for l in lines {
l.map_err(|e| e.to_string()).and_then(|l| { l.map_err(|e| e.to_string()).and_then(|l| {
let l = format_string(l, &options)?; let l = format_string(l, &options)?;
Ok(println!("{}", l)) println!("{}", l);
Ok(())
})? })?
} }
Ok(()) Ok(())

View file

@ -80,7 +80,7 @@ fn options(args: &[String]) -> Result<Options> {
fn exec(options: Options) -> Result<()> { fn exec(options: Options) -> Result<()> {
match options.print_and_exit { match options.print_and_exit {
Some(text) => Ok(println!("{}", text)), Some(text) => { println!("{}", text); Ok(()) },
None => tee(options), None => tee(options),
} }
} }