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 (unneeded format)

This commit is contained in:
Roy Ivy III 2019-12-28 11:36:33 -06:00
parent 3bff70967c
commit 25b1f98cf8
4 changed files with 7 additions and 9 deletions

View file

@ -979,7 +979,7 @@ fn copy_attribute(source: &Path, dest: &Path, attribute: &Attribute) -> CopyResu
} }
#[cfg(not(unix))] #[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<()> { fn copy_helper(source: &Path, dest: &Path, options: &Options) -> CopyResult<()> {
if options.reflink { if options.reflink {
#[cfg(not(target_os = "linux"))] #[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")] #[cfg(target_os = "linux")]
{ {

View file

@ -224,7 +224,7 @@ impl OdOptions {
let formats = match parse_format_flags(&args) { let formats = match parse_format_flags(&args) {
Ok(f) => f, Ok(f) => f,
Err(e) => { Err(e) => {
return Err(format!("{}", e)); return Err(e.to_string());
} }
}; };
@ -260,7 +260,7 @@ impl OdOptions {
Some(s) => { Some(s) => {
let st = s.into_bytes(); let st = s.into_bytes();
if st.len() != 1 { 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 { } else {
let radix: char = let radix: char =
*(st.get(0).expect("byte string of length 1 lacks a 0th elem")) as 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, 'x' => Radix::Hexadecimal,
'o' => Radix::Octal, 'o' => Radix::Octal,
'n' => Radix::NoPrefix, '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()),
} }
} }
} }

View file

@ -155,9 +155,7 @@ pub fn parse_format_flags(args: &Vec<String>) -> Result<Vec<ParsedFormatterItemI
} }
} }
if expect_type_string { if expect_type_string {
return Err(format!( return Err("missing format specification after '--format' / '-t'".to_string());
"missing format specification after '--format' / '-t'"
));
} }
if formats.is_empty() { if formats.is_empty() {

View file

@ -271,7 +271,7 @@ fn get_reference(config: &Config, word_ref: &WordRef, line: &str) -> String {
Some(x) => (x.start(), x.end()), Some(x) => (x.start(), x.end()),
None => (0, 0), None => (0, 0),
}; };
format!("{}", &line[beg..end]) line[beg..end].to_string()
} else { } else {
String::new() String::new()
} }