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

Merge pull request #1997 from sylvestre/polish3

Rustfmt+clippy+cargo.lock update
This commit is contained in:
Sylvestre Ledru 2021-04-02 11:37:56 +02:00 committed by GitHub
commit de6aa69259
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 24 additions and 26 deletions

10
Cargo.lock generated
View file

@ -1,7 +1,5 @@
# This file is automatically @generated by Cargo. # This file is automatically @generated by Cargo.
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3
[[package]] [[package]]
name = "advapi32-sys" name = "advapi32-sys"
version = "0.2.0" version = "0.2.0"
@ -982,9 +980,9 @@ checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.24" version = "1.0.26"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" checksum = "a152013215dca273577e18d2bf00fa862b89b24169fb78c4c95aeb07992c9cec"
dependencies = [ dependencies = [
"unicode-xid 0.2.1", "unicode-xid 0.2.1",
] ]
@ -1356,9 +1354,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a"
[[package]] [[package]]
name = "syn" name = "syn"
version = "1.0.67" version = "1.0.68"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6498a9efc342871f91cc2d0d694c674368b4ceb40f62b65a7a08c3792935e702" checksum = "3ce15dd3ed8aa2f8eeac4716d6ef5ab58b6b9256db41d7e1a0224c2788e8fd87"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote 1.0.9", "quote 1.0.9",

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

@ -26,9 +26,9 @@ use time::Timespec;
#[cfg(windows)] #[cfg(windows)]
use winapi::shared::minwindef::{DWORD, LPVOID}; use winapi::shared::minwindef::{DWORD, LPVOID};
#[cfg(windows)] #[cfg(windows)]
use winapi::um::fileapi::{FILE_STANDARD_INFO, FILE_ID_INFO}; use winapi::um::fileapi::{FILE_ID_INFO, FILE_STANDARD_INFO};
#[cfg(windows)] #[cfg(windows)]
use winapi::um::minwinbase::{FileStandardInfo, FileIdInfo}; use winapi::um::minwinbase::{FileIdInfo, FileStandardInfo};
#[cfg(windows)] #[cfg(windows)]
use winapi::um::winbase::GetFileInformationByHandleEx; use winapi::um::winbase::GetFileInformationByHandleEx;
#[cfg(windows)] #[cfg(windows)]

View file

@ -36,7 +36,6 @@ const AFTER_HELP: &str = r#"
\\xHH byte with hexadecimal value HH (1 to 2 digits) \\xHH byte with hexadecimal value HH (1 to 2 digits)
"#; "#;
mod options { mod options {
pub const STRING: &str = "STRING"; pub const STRING: &str = "STRING";
pub const NO_NEWLINE: &str = "no_newline"; pub const NO_NEWLINE: &str = "no_newline";

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

@ -493,13 +493,13 @@ fn get_leading_number(a: &str) -> &str {
fn num_sort_dedup(a: &str) -> &str { fn num_sort_dedup(a: &str) -> &str {
// Empty lines are dumped // Empty lines are dumped
if a.is_empty() { if a.is_empty() {
return "0" return "0";
// And lines that don't begin numerically are dumped // And lines that don't begin numerically are dumped
} else if !a.trim().chars().nth(0).unwrap_or('\0').is_numeric() { } else if !a.trim().chars().nth(0).unwrap_or('\0').is_numeric() {
return "0" return "0";
} else { } else {
// Prepare lines for comparison of only the numerical leading numbers // Prepare lines for comparison of only the numerical leading numbers
return get_leading_number(a) return get_leading_number(a);
}; };
} }

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)]