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

Merge pull request #1715 from sylvestre/clippy-fix2

Fix some clippy warnings
This commit is contained in:
Sylvestre Ledru 2021-02-07 16:43:12 +01:00 committed by GitHub
commit 749c794bf6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 12 deletions

View file

@ -495,7 +495,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
return Err(()); return Err(());
} }
if b.owner != "" { if !b.owner.is_empty() {
let meta = match fs::metadata(to) { let meta = match fs::metadata(to) {
Ok(meta) => meta, Ok(meta) => meta,
Err(f) => crash!(1, "{}", f.to_string()), Err(f) => crash!(1, "{}", f.to_string()),
@ -515,7 +515,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
Verbosity::Normal, Verbosity::Normal,
) { ) {
Ok(n) => { Ok(n) => {
if n != "" { if !n.is_empty() {
show_info!("{}", n); show_info!("{}", n);
} }
} }
@ -523,7 +523,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
} }
} }
if b.group != "" { if !b.group.is_empty() {
let meta = match fs::metadata(to) { let meta = match fs::metadata(to) {
Ok(meta) => meta, Ok(meta) => meta,
Err(f) => crash!(1, "{}", f.to_string()), Err(f) => crash!(1, "{}", f.to_string()),
@ -535,7 +535,7 @@ fn copy(from: &PathBuf, to: &PathBuf, b: &Behavior) -> Result<(), ()> {
}; };
match wrap_chgrp(to.as_path(), &meta, group_id, false, Verbosity::Normal) { match wrap_chgrp(to.as_path(), &meta, group_id, false, Verbosity::Normal) {
Ok(n) => { Ok(n) => {
if n != "" { if !n.is_empty() {
show_info!("{}", n); show_info!("{}", n);
} }
} }

View file

@ -325,9 +325,8 @@ fn link_files_in_dir(files: &[PathBuf], target_dir: &PathBuf, settings: &Setting
// Not sure why but on Windows, the symlink can be // Not sure why but on Windows, the symlink can be
// considered as a dir // considered as a dir
// See test_ln::test_symlink_no_deref_dir // See test_ln::test_symlink_no_deref_dir
match fs::remove_dir(target_dir) { if let Err(e) = fs::remove_dir(target_dir) {
Err(e) => show_error!("Could not update {}: {}", target_dir.display(), e), show_error!("Could not update {}: {}", target_dir.display(), e)
_ => (),
}; };
} }
} }

View file

@ -75,9 +75,7 @@ impl FilterWriter {
.spawn() .spawn()
.expect("Couldn't spawn filter command"); .expect("Couldn't spawn filter command");
FilterWriter { FilterWriter { shell_process }
shell_process: shell_process,
}
} }
} }

View file

@ -163,7 +163,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
match matches.value_of(OPT_LINES) { match matches.value_of(OPT_LINES) {
Some(n) => { Some(n) => {
let mut slice: &str = n.as_ref(); let mut slice: &str = n;
if slice.chars().next().unwrap_or('_') == '+' { if slice.chars().next().unwrap_or('_') == '+' {
settings.beginning = true; settings.beginning = true;
slice = &slice[1..]; slice = &slice[1..];
@ -178,7 +178,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 {
} }
None => { None => {
if let Some(n) = matches.value_of(OPT_BYTES) { if let Some(n) = matches.value_of(OPT_BYTES) {
let mut slice: &str = n.as_ref(); let mut slice: &str = n;
if slice.chars().next().unwrap_or('_') == '+' { if slice.chars().next().unwrap_or('_') == '+' {
settings.beginning = true; settings.beginning = true;
slice = &slice[1..]; slice = &slice[1..];