From 25b1f98cf8cbac60bf4981a91ed1b79c349e6ac3 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sat, 28 Dec 2019 11:36:33 -0600 Subject: [PATCH] refactor/polish ~ fix `cargo clippy` complaints (unneeded `format`) --- src/cp/cp.rs | 4 ++-- src/od/od.rs | 6 +++--- src/od/parse_formats.rs | 4 +--- src/ptx/ptx.rs | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/cp/cp.rs b/src/cp/cp.rs index c7e93bbac..f63a73cd9 100644 --- a/src/cp/cp.rs +++ b/src/cp/cp.rs @@ -979,7 +979,7 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu } #[cfg(not(unix))] { - return Err(format!("XAttrs are only supported on unix.").into()); + return Err("XAttrs are only supported on unix.".to_string().into()); } } }) @@ -1114,7 +1114,7 @@ fn copy_file(source: &Path, dest: &Path, options: &Options) -> CopyResult<()> { fn copy_helper(source: &Path, dest: &Path, options: &Options) -> CopyResult<()> { if options.reflink { #[cfg(not(target_os = "linux"))] - return Err(format!("--reflink is only supported on linux").into()); + return Err("--reflink is only supported on linux".to_string().into()); #[cfg(target_os = "linux")] { diff --git a/src/od/od.rs b/src/od/od.rs index 001d829eb..8967a5e8c 100644 --- a/src/od/od.rs +++ b/src/od/od.rs @@ -224,7 +224,7 @@ impl OdOptions { let formats = match parse_format_flags(&args) { Ok(f) => f, Err(e) => { - return Err(format!("{}", e)); + return Err(e.to_string()); } }; @@ -260,7 +260,7 @@ impl OdOptions { Some(s) => { let st = s.into_bytes(); if st.len() != 1 { - return Err(format!("Radix must be one of [d, o, n, x]")); + return Err("Radix must be one of [d, o, n, x]".to_string()); } else { let radix: char = *(st.get(0).expect("byte string of length 1 lacks a 0th elem")) as char; @@ -269,7 +269,7 @@ impl OdOptions { 'x' => Radix::Hexadecimal, 'o' => Radix::Octal, 'n' => Radix::NoPrefix, - _ => return Err(format!("Radix must be one of [d, o, n, x]")), + _ => return Err("Radix must be one of [d, o, n, x]".to_string()), } } } diff --git a/src/od/parse_formats.rs b/src/od/parse_formats.rs index 9a431aeb9..a900a8eb4 100644 --- a/src/od/parse_formats.rs +++ b/src/od/parse_formats.rs @@ -155,9 +155,7 @@ pub fn parse_format_flags(args: &Vec) -> Result String { Some(x) => (x.start(), x.end()), None => (0, 0), }; - format!("{}", &line[beg..end]) + line[beg..end].to_string() } else { String::new() }