1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Fix some clippy warnings

This commit is contained in:
Sylvestre Ledru 2021-04-01 23:37:22 +02:00
parent 6734ce785d
commit dcbcf01665
9 changed files with 14 additions and 13 deletions

View file

@ -147,7 +147,7 @@ fn cksum(fname: &str) -> io::Result<(u32, usize)> {
"Is a directory", "Is a directory",
)); ));
}; };
if !path.metadata().is_ok() { if path.metadata().is_err() {
return Err(std::io::Error::new( return Err(std::io::Error::new(
io::ErrorKind::NotFound, io::ErrorKind::NotFound,
"No such file or directory", "No such file or directory",

View file

@ -81,7 +81,7 @@ pub fn break_lines(para: &Paragraph, opts: &FmtOptions, ostream: &mut BufWriter<
let mut break_args = BreakArgs { let mut break_args = BreakArgs {
opts, opts,
init_len: p_init_len, init_len: p_init_len,
indent_str: &p_indent[..], indent_str: p_indent,
indent_len: p_indent_len, indent_len: p_indent_len,
uniform, uniform,
ostream, ostream,

View file

@ -223,7 +223,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
} else if matches.is_present(OPT_BACKUP) { } else if matches.is_present(OPT_BACKUP) {
match matches.value_of(OPT_BACKUP) { match matches.value_of(OPT_BACKUP) {
None => BackupMode::ExistingBackup, None => BackupMode::ExistingBackup,
Some(mode) => match &mode[..] { Some(mode) => match mode {
"simple" | "never" => BackupMode::SimpleBackup, "simple" | "never" => BackupMode::SimpleBackup,
"numbered" | "t" => BackupMode::NumberedBackup, "numbered" | "t" => BackupMode::NumberedBackup,
"existing" | "nil" => BackupMode::ExistingBackup, "existing" | "nil" => BackupMode::ExistingBackup,

View file

@ -270,14 +270,12 @@ impl Config {
.any(|i| i >= idx) .any(|i| i >= idx)
{ {
format = Format::Long; format = Format::Long;
} else { } else if let Some(mut indices) = options.indices_of(options::format::ONELINE) {
if let Some(mut indices) = options.indices_of(options::format::ONELINE) {
if indices.any(|i| i > idx) { if indices.any(|i| i > idx) {
format = Format::OneLine; format = Format::OneLine;
} }
} }
} }
}
let files = if options.is_present(options::files::ALL) { let files = if options.is_present(options::files::ALL) {
Files::All Files::All

View file

@ -37,7 +37,7 @@ pub fn parse_options(settings: &mut crate::Settings, opts: &clap::ArgMatches) ->
} }
match opts.value_of(options::NUMBER_FORMAT) { match opts.value_of(options::NUMBER_FORMAT) {
None => {} None => {}
Some(val) => match val.as_ref() { Some(val) => match val {
"ln" => { "ln" => {
settings.number_format = crate::NumberFormat::Left; settings.number_format = crate::NumberFormat::Left;
} }

View file

@ -59,7 +59,7 @@ fn get_primitive_hex(
// assign 0 // assign 0
let (mut first_segment_raw, second_segment_raw) = match analysis.decimal_pos { let (mut first_segment_raw, second_segment_raw) = match analysis.decimal_pos {
Some(pos) => (&str_in[..pos], &str_in[pos + 1..]), Some(pos) => (&str_in[..pos], &str_in[pos + 1..]),
None => (&str_in[..], "0"), None => (str_in, "0"),
}; };
if first_segment_raw.is_empty() { if first_segment_raw.is_empty() {
first_segment_raw = "0"; first_segment_raw = "0";

View file

@ -218,7 +218,7 @@ pub fn get_primitive_dec(
// assign 0 // assign 0
let (mut first_segment_raw, second_segment_raw) = match analysis.decimal_pos { let (mut first_segment_raw, second_segment_raw) = match analysis.decimal_pos {
Some(pos) => (&str_in[..pos], &str_in[pos + 1..]), Some(pos) => (&str_in[..pos], &str_in[pos + 1..]),
None => (&str_in[..], "0"), None => (str_in, "0"),
}; };
if first_segment_raw.is_empty() { if first_segment_raw.is_empty() {
first_segment_raw = "0"; first_segment_raw = "0";

View file

@ -338,7 +338,7 @@ this is the default for non-regular files",
Some(s) => match s.parse::<usize>() { Some(s) => match s.parse::<usize>() {
Ok(u) => u, Ok(u) => u,
Err(_) => { Err(_) => {
errs.push(String::from(format!("invalid number of passes: '{}'", s))); errs.push(format!("invalid number of passes: '{}'", s));
0 0
} }
}, },

View file

@ -1,8 +1,11 @@
#![allow(dead_code)] #![allow(dead_code)]
#[cfg(not(windows))]
use libc; use libc;
use std::env; use std::env;
use std::ffi::{CString, OsStr}; #[cfg(not(windows))]
use std::ffi::CString;
use std::ffi::OsStr;
use std::fs::{self, File, OpenOptions}; use std::fs::{self, File, OpenOptions};
use std::io::{Read, Result, Write}; use std::io::{Read, Result, Write};
#[cfg(unix)] #[cfg(unix)]