mirror of
https://github.com/uutils/coreutils
synced 2024-12-13 14:52:41 +00:00
Merge pull request #4303 from cakebaker/clippy
clippy: fix warnings introduced with Rust 1.67.0
This commit is contained in:
commit
8c6d0e7630
172 changed files with 835 additions and 1034 deletions
|
@ -424,7 +424,7 @@ fn get_input_type(path: &str) -> CatResult<InputType> {
|
|||
ft if ft.is_file() => Ok(InputType::File),
|
||||
ft if ft.is_symlink() => Ok(InputType::SymLink),
|
||||
_ => Err(CatError::UnknownFiletype {
|
||||
ft_debug: format!("{:?}", ft),
|
||||
ft_debug: format!("{ft:?}"),
|
||||
}),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
return Err(r.into());
|
||||
}
|
||||
|
||||
return Err(UUsageError::new(libc::EXIT_FAILURE, format!("{}.\n", r)));
|
||||
return Err(UUsageError::new(libc::EXIT_FAILURE, format!("{r}.\n")));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -67,10 +67,10 @@ impl Error {
|
|||
|
||||
pub(crate) fn report_full_error(mut err: &dyn std::error::Error) -> String {
|
||||
let mut desc = String::with_capacity(256);
|
||||
write!(desc, "{}", err).unwrap();
|
||||
write!(desc, "{err}").unwrap();
|
||||
while let Some(source) = err.source() {
|
||||
err = source;
|
||||
write!(desc, ". {}", err).unwrap();
|
||||
write!(desc, ". {err}").unwrap();
|
||||
}
|
||||
desc
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let modes = matches.get_one::<String>(options::MODE).unwrap(); // should always be Some because required
|
||||
let cmode = if mode_had_minus_prefix {
|
||||
// clap parsing is finished, now put prefix back
|
||||
format!("-{}", modes)
|
||||
format!("-{modes}")
|
||||
} else {
|
||||
modes.to_string()
|
||||
};
|
||||
|
|
|
@ -77,8 +77,8 @@ impl Display for ChrootError {
|
|||
"cannot change root directory to {}: no such directory",
|
||||
s.quote(),
|
||||
),
|
||||
Self::SetGidFailed(s, e) => write!(f, "cannot set gid to {}: {}", s, e),
|
||||
Self::SetGroupsFailed(e) => write!(f, "cannot set groups: {}", e),
|
||||
Self::SetGidFailed(s, e) => write!(f, "cannot set gid to {s}: {e}"),
|
||||
Self::SetGroupsFailed(e) => write!(f, "cannot set groups: {e}"),
|
||||
Self::SetUserFailed(s, e) => {
|
||||
write!(f, "cannot set user to {}: {}", s.maybe_quote(), e)
|
||||
}
|
||||
|
|
|
@ -123,13 +123,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
if files.is_empty() {
|
||||
let (crc, size) = cksum("-")?;
|
||||
println!("{} {}", crc, size);
|
||||
println!("{crc} {size}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
for fname in &files {
|
||||
match cksum(fname.as_ref()).map_err_context(|| format!("{}", fname.maybe_quote())) {
|
||||
Ok((crc, size)) => println!("{} {} {}", crc, size, fname),
|
||||
Ok((crc, size)) => println!("{crc} {size} {fname}"),
|
||||
Err(err) => show!(err),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -380,7 +380,7 @@ pub(crate) fn copy_directory(
|
|||
// the target directory.
|
||||
let context = match Context::new(root, target) {
|
||||
Ok(c) => c,
|
||||
Err(e) => return Err(format!("failed to get current directory {}", e).into()),
|
||||
Err(e) => return Err(format!("failed to get current directory {e}").into()),
|
||||
};
|
||||
|
||||
// Traverse the contents of the directory, copying each one.
|
||||
|
|
|
@ -746,7 +746,7 @@ impl Options {
|
|||
let recursive = matches.get_flag(options::RECURSIVE) || matches.get_flag(options::ARCHIVE);
|
||||
|
||||
let backup_mode = match backup_control::determine_backup_mode(matches) {
|
||||
Err(e) => return Err(Error::Backup(format!("{}", e))),
|
||||
Err(e) => return Err(Error::Backup(format!("{e}"))),
|
||||
Ok(mode) => mode,
|
||||
};
|
||||
|
||||
|
@ -865,8 +865,7 @@ impl Options {
|
|||
"never" => SparseMode::Never,
|
||||
_ => {
|
||||
return Err(Error::InvalidArgument(format!(
|
||||
"invalid argument {} for \'sparse\'",
|
||||
val
|
||||
"invalid argument {val} for \'sparse\'"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
@ -1857,7 +1856,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_aligned_ancestors() {
|
||||
let actual = aligned_ancestors(&Path::new("a/b/c"), &Path::new("d/a/b/c"));
|
||||
let actual = aligned_ancestors(Path::new("a/b/c"), Path::new("d/a/b/c"));
|
||||
let expected = vec![
|
||||
(Path::new("a"), Path::new("d/a")),
|
||||
(Path::new("a/b"), Path::new("d/a/b")),
|
||||
|
|
|
@ -69,9 +69,7 @@ pub(crate) fn copy_on_write(
|
|||
// support COW).
|
||||
match reflink_mode {
|
||||
ReflinkMode::Always => {
|
||||
return Err(
|
||||
format!("failed to clone {:?} from {:?}: {}", source, dest, error).into(),
|
||||
)
|
||||
return Err(format!("failed to clone {source:?} from {dest:?}: {error}").into())
|
||||
}
|
||||
_ => {
|
||||
if source_is_fifo {
|
||||
|
|
|
@ -574,7 +574,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -583,7 +583,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(1, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -595,7 +595,7 @@ mod tests {
|
|||
);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
input_splitter.rewind_buffer();
|
||||
|
@ -605,7 +605,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("bbb"));
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -613,7 +613,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("ccc"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -621,7 +621,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("ddd"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
assert!(input_splitter.next().is_none());
|
||||
|
@ -646,7 +646,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -655,7 +655,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(1, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -664,7 +664,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(2, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 3);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
input_splitter.rewind_buffer();
|
||||
|
@ -675,7 +675,7 @@ mod tests {
|
|||
assert_eq!(input_splitter.add_line_to_buffer(0, line), None);
|
||||
assert_eq!(input_splitter.buffer_len(), 3);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -683,7 +683,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("aaa"));
|
||||
assert_eq!(input_splitter.buffer_len(), 2);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -691,7 +691,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("bbb"));
|
||||
assert_eq!(input_splitter.buffer_len(), 1);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -699,7 +699,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("ccc"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
match input_splitter.next() {
|
||||
|
@ -707,7 +707,7 @@ mod tests {
|
|||
assert_eq!(line, String::from("ddd"));
|
||||
assert_eq!(input_splitter.buffer_len(), 0);
|
||||
}
|
||||
item => panic!("wrong item: {:?}", item),
|
||||
item => panic!("wrong item: {item:?}"),
|
||||
};
|
||||
|
||||
assert!(input_splitter.next().is_none());
|
||||
|
|
|
@ -224,35 +224,35 @@ mod tests {
|
|||
assert_eq!(patterns.len(), 5);
|
||||
match patterns.get(0) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test1.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(1) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Always)) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test2.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(2) {
|
||||
Some(Pattern::UpToMatch(reg, 0, ExecutePattern::Times(5))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test3.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(3) {
|
||||
Some(Pattern::UpToMatch(reg, 3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test4.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
};
|
||||
match patterns.get(4) {
|
||||
Some(Pattern::UpToMatch(reg, -3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test5.*end$");
|
||||
}
|
||||
_ => panic!("expected UpToMatch pattern"),
|
||||
|
@ -277,35 +277,35 @@ mod tests {
|
|||
assert_eq!(patterns.len(), 5);
|
||||
match patterns.get(0) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test1.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(1) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Always)) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test2.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(2) {
|
||||
Some(Pattern::SkipToMatch(reg, 0, ExecutePattern::Times(5))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test3.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(3) {
|
||||
Some(Pattern::SkipToMatch(reg, 3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test4.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
};
|
||||
match patterns.get(4) {
|
||||
Some(Pattern::SkipToMatch(reg, -3, ExecutePattern::Times(1))) => {
|
||||
let parsed_reg = format!("{}", reg);
|
||||
let parsed_reg = format!("{reg}");
|
||||
assert_eq!(parsed_reg, "test5.*end$");
|
||||
}
|
||||
_ => panic!("expected SkipToMatch pattern"),
|
||||
|
|
|
@ -42,9 +42,7 @@ impl SplitName {
|
|||
.unwrap_or(2);
|
||||
// translate the custom format into a function
|
||||
let fn_split_name: Box<dyn Fn(usize) -> String> = match format_opt {
|
||||
None => Box::new(move |n: usize| -> String {
|
||||
format!("{}{:0width$}", prefix, n, width = n_digits)
|
||||
}),
|
||||
None => Box::new(move |n: usize| -> String { format!("{prefix}{n:0n_digits$}") }),
|
||||
Some(custom) => {
|
||||
let spec =
|
||||
Regex::new(r"(?P<ALL>%((?P<FLAG>[0#-])(?P<WIDTH>\d+)?)?(?P<TYPE>[diuoxX]))")
|
||||
|
@ -62,16 +60,16 @@ impl SplitName {
|
|||
match (captures.name("FLAG"), captures.name("TYPE")) {
|
||||
(None, Some(ref t)) => match t.as_str() {
|
||||
"d" | "i" | "u" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n}{after}")
|
||||
}),
|
||||
"o" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:o}{after}")
|
||||
}),
|
||||
"x" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:x}{after}")
|
||||
}),
|
||||
"X" => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:X}{after}")
|
||||
}),
|
||||
_ => return Err(CsplitError::SuffixFormatIncorrect),
|
||||
},
|
||||
|
@ -82,19 +80,19 @@ impl SplitName {
|
|||
*/
|
||||
// decimal
|
||||
("0", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$}{after}")
|
||||
}),
|
||||
// octal
|
||||
("0", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("0", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("0", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:0width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:0width$X}{after}")
|
||||
}),
|
||||
|
||||
/*
|
||||
|
@ -102,15 +100,15 @@ impl SplitName {
|
|||
*/
|
||||
// octal
|
||||
("#", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("#", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("#", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:>#width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:>#width$X}{after}")
|
||||
}),
|
||||
|
||||
/*
|
||||
|
@ -118,19 +116,19 @@ impl SplitName {
|
|||
*/
|
||||
// decimal
|
||||
("-", "d" | "i" | "u") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$}{after}")
|
||||
}),
|
||||
// octal
|
||||
("-", "o") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$o}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$o}{after}")
|
||||
}),
|
||||
// lower hexadecimal
|
||||
("-", "x") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$x}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$x}{after}")
|
||||
}),
|
||||
// upper hexadecimal
|
||||
("-", "X") => Box::new(move |n: usize| -> String {
|
||||
format!("{}{}{:<#width$X}{}", prefix, before, n, after)
|
||||
format!("{prefix}{before}{n:<#width$X}{after}")
|
||||
}),
|
||||
|
||||
_ => return Err(CsplitError::SuffixFormatIncorrect),
|
||||
|
|
|
@ -117,7 +117,7 @@ impl<'a> From<&'a str> for Iso8601Format {
|
|||
NS => Self::Ns,
|
||||
DATE => Self::Date,
|
||||
// Should be caught by clap
|
||||
_ => panic!("Invalid format: {}", s),
|
||||
_ => panic!("Invalid format: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -135,7 +135,7 @@ impl<'a> From<&'a str> for Rfc3339Format {
|
|||
SECONDS | SECOND => Self::Seconds,
|
||||
NS => Self::Ns,
|
||||
// Should be caught by clap
|
||||
_ => panic!("Invalid format: {}", s),
|
||||
_ => panic!("Invalid format: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -257,7 +257,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
.format_with_items(format_items)
|
||||
.to_string()
|
||||
.replace("%f", "%N");
|
||||
println!("{}", formatted);
|
||||
println!("{formatted}");
|
||||
}
|
||||
Err((input, _err)) => show_error!("invalid date {}", input.quote()),
|
||||
}
|
||||
|
|
|
@ -772,9 +772,7 @@ fn is_stdout_redirected_to_seekable_file() -> bool {
|
|||
let p = Path::new(&s);
|
||||
match File::open(p) {
|
||||
Ok(mut f) => {
|
||||
f.seek(SeekFrom::Current(0)).is_ok()
|
||||
&& f.seek(SeekFrom::End(0)).is_ok()
|
||||
&& f.seek(SeekFrom::Start(0)).is_ok()
|
||||
f.stream_position().is_ok() && f.seek(SeekFrom::End(0)).is_ok() && f.rewind().is_ok()
|
||||
}
|
||||
Err(_) => false,
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
|||
//
|
||||
let quotient = (n as f64) / (base as f64);
|
||||
if quotient < 10.0 {
|
||||
format!("{:.1} {}", quotient, suffix)
|
||||
format!("{quotient:.1} {suffix}")
|
||||
} else {
|
||||
format!("{} {}", quotient.round(), suffix)
|
||||
}
|
||||
|
|
|
@ -394,7 +394,7 @@ impl std::fmt::Display for ParseError {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::UnrecognizedOperand(arg) => {
|
||||
write!(f, "Unrecognized operand '{}'", arg)
|
||||
write!(f, "Unrecognized operand '{arg}'")
|
||||
}
|
||||
Self::MultipleFmtTable => {
|
||||
write!(
|
||||
|
@ -421,32 +421,31 @@ impl std::fmt::Display for ParseError {
|
|||
)
|
||||
}
|
||||
Self::ConvFlagNoMatch(arg) => {
|
||||
write!(f, "Unrecognized conv=CONV -> {}", arg)
|
||||
write!(f, "Unrecognized conv=CONV -> {arg}")
|
||||
}
|
||||
Self::MultiplierStringParseFailure(arg) => {
|
||||
write!(f, "Unrecognized byte multiplier -> {}", arg)
|
||||
write!(f, "Unrecognized byte multiplier -> {arg}")
|
||||
}
|
||||
Self::MultiplierStringOverflow(arg) => {
|
||||
write!(
|
||||
f,
|
||||
"Multiplier string would overflow on current system -> {}",
|
||||
arg
|
||||
"Multiplier string would overflow on current system -> {arg}"
|
||||
)
|
||||
}
|
||||
Self::BlockUnblockWithoutCBS => {
|
||||
write!(f, "conv=block or conv=unblock specified without cbs=N")
|
||||
}
|
||||
Self::StatusLevelNotRecognized(arg) => {
|
||||
write!(f, "status=LEVEL not recognized -> {}", arg)
|
||||
write!(f, "status=LEVEL not recognized -> {arg}")
|
||||
}
|
||||
Self::BsOutOfRange(arg) => {
|
||||
write!(f, "{}=N cannot fit into memory", arg)
|
||||
write!(f, "{arg}=N cannot fit into memory")
|
||||
}
|
||||
Self::Unimplemented(arg) => {
|
||||
write!(f, "feature not implemented on this system -> {}", arg)
|
||||
write!(f, "feature not implemented on this system -> {arg}")
|
||||
}
|
||||
Self::InvalidNumber(arg) => {
|
||||
write!(f, "invalid number: ‘{}’", arg)
|
||||
write!(f, "invalid number: ‘{arg}’")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,29 +56,28 @@ fn unimplemented_flags_should_error() {
|
|||
|
||||
// The following flags are not implemented
|
||||
for flag in ["cio", "nocache", "nolinks", "text", "binary"] {
|
||||
let args = vec![format!("iflag={}", flag)];
|
||||
let args = vec![format!("iflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
|
||||
let args = vec![format!("oflag={}", flag)];
|
||||
let args = vec![format!("oflag={flag}")];
|
||||
|
||||
if Parser::new()
|
||||
.parse(&args.iter().map(AsRef::as_ref).collect::<Vec<_>>()[..])
|
||||
.is_ok()
|
||||
{
|
||||
succeeded.push(format!("iflag={}", flag));
|
||||
succeeded.push(format!("iflag={flag}"));
|
||||
}
|
||||
}
|
||||
|
||||
assert!(
|
||||
succeeded.is_empty(),
|
||||
"The following flags did not panic as expected: {:?}",
|
||||
succeeded
|
||||
"The following flags did not panic as expected: {succeeded:?}"
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -100,7 +100,7 @@ impl ProgUpdate {
|
|||
match self.read_stat.records_truncated {
|
||||
0 => {}
|
||||
1 => writeln!(w, "1 truncated record")?,
|
||||
n => writeln!(w, "{} truncated records", n)?,
|
||||
n => writeln!(w, "{n} truncated records")?,
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -154,29 +154,19 @@ impl ProgUpdate {
|
|||
match btotal {
|
||||
1 => write!(
|
||||
w,
|
||||
"{}{} byte copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} byte copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
0..=999 => write!(
|
||||
w,
|
||||
"{}{} bytes copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} bytes copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
1000..=1023 => write!(
|
||||
w,
|
||||
"{}{} bytes ({}) copied, {:.1} s, {}/s{}",
|
||||
carriage_return, btotal, btotal_metric, duration, transfer_rate, newline,
|
||||
"{carriage_return}{btotal} bytes ({btotal_metric}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
_ => write!(
|
||||
w,
|
||||
"{}{} bytes ({}, {}) copied, {:.1} s, {}/s{}",
|
||||
carriage_return,
|
||||
btotal,
|
||||
btotal_metric,
|
||||
btotal_bin,
|
||||
duration,
|
||||
transfer_rate,
|
||||
newline,
|
||||
"{carriage_return}{btotal} bytes ({btotal_metric}, {btotal_bin}) copied, {duration:.1} s, {transfer_rate}/s{newline}",
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -455,10 +445,7 @@ pub(crate) fn gen_prog_updater(
|
|||
|
||||
register_linux_signal_handler(sigval.clone()).unwrap_or_else(|e| {
|
||||
if Some(StatusLevel::None) != print_level {
|
||||
eprintln!(
|
||||
"Internal dd Warning: Unable to register signal handler \n\t{}",
|
||||
e
|
||||
);
|
||||
eprintln!("Internal dd Warning: Unable to register signal handler \n\t{e}");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -91,12 +91,12 @@ pub(crate) fn to_magnitude_and_suffix(n: u128, suffix_type: SuffixType) -> Strin
|
|||
let suffix = suffixes[i];
|
||||
|
||||
if rem == 0 {
|
||||
format!("{}{}", quot, suffix)
|
||||
format!("{quot}{suffix}")
|
||||
} else {
|
||||
let tenths_place = rem / (bases[i] / 10);
|
||||
|
||||
if rem % (bases[i] / 10) == 0 {
|
||||
format!("{}.{}{}", quot, tenths_place, suffix)
|
||||
format!("{quot}.{tenths_place}{suffix}")
|
||||
} else if tenths_place + 1 == 10 || quot >= 10 {
|
||||
format!("{}{}", quot + 1, suffix)
|
||||
} else {
|
||||
|
@ -205,7 +205,7 @@ impl fmt::Display for BlockSize {
|
|||
to_magnitude_and_suffix(*n as u128, SuffixType::Si)
|
||||
};
|
||||
|
||||
write!(f, "{}", s)
|
||||
write!(f, "{s}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -146,10 +146,10 @@ impl fmt::Display for OptionsError {
|
|||
}
|
||||
// TODO This needs to vary based on whether `--block-size`
|
||||
// or `-B` were provided.
|
||||
Self::InvalidBlockSize(s) => write!(f, "invalid --block-size argument {}", s),
|
||||
Self::InvalidBlockSize(s) => write!(f, "invalid --block-size argument {s}"),
|
||||
// TODO This needs to vary based on whether `--block-size`
|
||||
// or `-B` were provided.
|
||||
Self::InvalidSuffix(s) => write!(f, "invalid suffix in --block-size argument {}", s),
|
||||
Self::InvalidSuffix(s) => write!(f, "invalid suffix in --block-size argument {s}"),
|
||||
Self::ColumnError(ColumnError::MultipleColumns(s)) => write!(
|
||||
f,
|
||||
"option --output: field {} used more than once",
|
||||
|
|
|
@ -438,7 +438,7 @@ impl fmt::Display for Table {
|
|||
Alignment::Left => {
|
||||
if is_last_col {
|
||||
// no trailing spaces in last column
|
||||
write!(f, "{}", elem)?;
|
||||
write!(f, "{elem}")?;
|
||||
} else {
|
||||
write!(f, "{:<width$}", elem, width = self.widths[i])?;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
),
|
||||
));
|
||||
}
|
||||
println!("{}", INTERNAL_DB);
|
||||
println!("{INTERNAL_DB}");
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
match result {
|
||||
Ok(s) => {
|
||||
println!("{}", s);
|
||||
println!("{s}");
|
||||
Ok(())
|
||||
}
|
||||
Err(s) => {
|
||||
|
@ -368,23 +368,23 @@ where
|
|||
if state != ParseState::Pass {
|
||||
if key.starts_with('.') {
|
||||
if *fmt == OutputFmt::Display {
|
||||
result.push_str(format!("\x1b[{1}m*{0}\t{1}\x1b[0m\n", key, val).as_str());
|
||||
result.push_str(format!("\x1b[{val}m*{key}\t{val}\x1b[0m\n").as_str());
|
||||
} else {
|
||||
result.push_str(format!("*{}={}:", key, val).as_str());
|
||||
result.push_str(format!("*{key}={val}:").as_str());
|
||||
}
|
||||
} else if key.starts_with('*') {
|
||||
if *fmt == OutputFmt::Display {
|
||||
result.push_str(format!("\x1b[{1}m{0}\t{1}\x1b[0m\n", key, val).as_str());
|
||||
result.push_str(format!("\x1b[{val}m{key}\t{val}\x1b[0m\n").as_str());
|
||||
} else {
|
||||
result.push_str(format!("{}={}:", key, val).as_str());
|
||||
result.push_str(format!("{key}={val}:").as_str());
|
||||
}
|
||||
} else if lower == "options" || lower == "color" || lower == "eightbit" {
|
||||
// Slackware only. Ignore
|
||||
} else if let Some(s) = table.get(lower.as_str()) {
|
||||
if *fmt == OutputFmt::Display {
|
||||
result.push_str(format!("\x1b[{1}m{0}\t{1}\x1b[0m\n", s, val).as_str());
|
||||
result.push_str(format!("\x1b[{val}m{s}\t{val}\x1b[0m\n").as_str());
|
||||
} else {
|
||||
result.push_str(format!("{}={}:", s, val).as_str());
|
||||
result.push_str(format!("{s}={val}:").as_str());
|
||||
}
|
||||
} else {
|
||||
return Err(format!(
|
||||
|
|
|
@ -63,7 +63,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
print!("{}", separator);
|
||||
print!("{separator}");
|
||||
}
|
||||
} else {
|
||||
return Err(UUsageError::new(1, "missing operand"));
|
||||
|
|
|
@ -389,7 +389,7 @@ fn convert_size_human(size: u64, multiplier: u64, _block_size: u64) -> String {
|
|||
if size == 0 {
|
||||
return "0".to_string();
|
||||
}
|
||||
format!("{}B", size)
|
||||
format!("{size}B")
|
||||
}
|
||||
|
||||
fn convert_size_b(size: u64, _multiplier: u64, _block_size: u64) -> String {
|
||||
|
@ -448,7 +448,7 @@ Try '{} --help' for more information.",
|
|||
'birth' and 'creation' arguments are not supported on this platform.",
|
||||
s.quote()
|
||||
),
|
||||
Self::InvalidGlob(s) => write!(f, "Invalid exclude syntax: {}", s),
|
||||
Self::InvalidGlob(s) => write!(f, "Invalid exclude syntax: {s}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -650,12 +650,12 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let time_str = tm.format(time_format_str).to_string();
|
||||
print!("{}\t{}\t", convert_size(size), time_str);
|
||||
print_verbatim(stat.path).unwrap();
|
||||
print!("{}", line_separator);
|
||||
print!("{line_separator}");
|
||||
}
|
||||
} else if !summarize || index == len - 1 {
|
||||
print!("{}\t", convert_size(size));
|
||||
print_verbatim(stat.path).unwrap();
|
||||
print!("{}", line_separator);
|
||||
print!("{line_separator}");
|
||||
}
|
||||
if options.total && index == (len - 1) {
|
||||
// The last element will be the total size of the the path under
|
||||
|
@ -674,7 +674,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
if options.total {
|
||||
print!("{}\ttotal", convert_size(grand_total));
|
||||
print!("{}", line_separator);
|
||||
print!("{line_separator}");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
@ -103,7 +103,7 @@ fn print_escaped(input: &str, mut output: impl Write) -> io::Result<bool> {
|
|||
|
||||
// because printing char slices is apparently not available in the standard library
|
||||
for ch in &buffer[start..] {
|
||||
write!(output, "{}", ch)?;
|
||||
write!(output, "{ch}")?;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ fn execute(no_newline: bool, escaped: bool, free: &[String]) -> io::Result<()> {
|
|||
break;
|
||||
}
|
||||
} else {
|
||||
write!(output, "{}", input)?;
|
||||
write!(output, "{input}")?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
src/uu/env/src/env.rs
vendored
2
src/uu/env/src/env.rs
vendored
|
@ -210,7 +210,7 @@ fn run_env(args: impl uucore::Args) -> UResult<()> {
|
|||
Err(error) => {
|
||||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("cannot change directory to \"{}\": {}", d, error),
|
||||
format!("cannot change directory to \"{d}\": {error}"),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -255,7 +255,7 @@ fn expand_shortcuts(args: &[String]) -> Vec<String> {
|
|||
arg[1..]
|
||||
.split(',')
|
||||
.filter(|s| !s.is_empty())
|
||||
.for_each(|s| processed_args.push(format!("--tabs={}", s)));
|
||||
.for_each(|s| processed_args.push(format!("--tabs={s}")));
|
||||
} else {
|
||||
processed_args.push(arg.to_string());
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ fn process_expr(token_strings: &[&str]) -> Result<String, String> {
|
|||
}
|
||||
|
||||
fn print_expr_ok(expr_result: &str) -> UResult<()> {
|
||||
println!("{}", expr_result);
|
||||
println!("{expr_result}");
|
||||
if expr_result.parse::<i32>() == Ok(0) || expr_result.is_empty() {
|
||||
Err(1.into())
|
||||
} else {
|
||||
|
|
|
@ -151,7 +151,7 @@ impl AstNode {
|
|||
"index" => Ok(prefix_operator_index(&operand_values)),
|
||||
"substr" => Ok(prefix_operator_substr(&operand_values)),
|
||||
|
||||
_ => Err(format!("operation not implemented: {}", op_type)),
|
||||
_ => Err(format!("operation not implemented: {op_type}")),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ fn maybe_dump_ast(result: &Result<Box<AstNode>, String>) {
|
|||
println!("EXPR_DEBUG_AST");
|
||||
match result {
|
||||
Ok(ast) => ast.debug_dump(),
|
||||
Err(reason) => println!("\terr: {:?}", reason),
|
||||
Err(reason) => println!("\terr: {reason:?}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ fn maybe_dump_rpn(rpn: &TokenStack) {
|
|||
if debug_var == "1" {
|
||||
println!("EXPR_DEBUG_RPN");
|
||||
for token in rpn {
|
||||
println!("\t{:?}", token);
|
||||
println!("\t{token:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ fn ast_from_rpn(rpn: &mut TokenStack) -> Result<Box<AstNode>, String> {
|
|||
}
|
||||
|
||||
Some((token_idx, unexpected_token)) => {
|
||||
panic!("unexpected token at #{} {:?}", token_idx, unexpected_token)
|
||||
panic!("unexpected token at #{token_idx} {unexpected_token:?}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -266,14 +266,12 @@ fn move_rest_of_ops_to_out(
|
|||
None => return Ok(()),
|
||||
Some((token_idx, Token::ParOpen)) => {
|
||||
return Err(format!(
|
||||
"syntax error (Mismatched open-parenthesis at #{})",
|
||||
token_idx
|
||||
"syntax error (Mismatched open-parenthesis at #{token_idx})"
|
||||
))
|
||||
}
|
||||
Some((token_idx, Token::ParClose)) => {
|
||||
return Err(format!(
|
||||
"syntax error (Mismatched close-parenthesis at #{})",
|
||||
token_idx
|
||||
"syntax error (Mismatched close-parenthesis at #{token_idx})"
|
||||
))
|
||||
}
|
||||
Some(other) => out_stack.push(other),
|
||||
|
@ -325,10 +323,10 @@ fn maybe_dump_shunting_yard_step(
|
|||
if let Ok(debug_var) = env::var("EXPR_DEBUG_SYA_STEP") {
|
||||
if debug_var == "1" {
|
||||
println!("EXPR_DEBUG_SYA_STEP");
|
||||
println!("\t{} => {:?}", token_idx, token);
|
||||
println!("\t\tout: {:?}", out_stack);
|
||||
println!("\t\top : {:?}", op_stack);
|
||||
println!("\t\tresult: {:?}", result);
|
||||
println!("\t{token_idx} => {token:?}");
|
||||
println!("\t\tout: {out_stack:?}");
|
||||
println!("\t\top : {op_stack:?}");
|
||||
println!("\t\tresult: {result:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ fn maybe_dump_tokens_acc(tokens_acc: &[(usize, Token)]) {
|
|||
if debug_var == "1" {
|
||||
println!("EXPR_DEBUG_TOKENS");
|
||||
for token in tokens_acc {
|
||||
println!("\t{:?}", token);
|
||||
println!("\t{token:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ fn main() {
|
|||
.and_then(|s| s.parse::<usize>().ok())
|
||||
.unwrap_or(DEFAULT_SIZE);
|
||||
|
||||
write!(file, "{}", PREAMBLE).unwrap();
|
||||
write!(file, "{PREAMBLE}").unwrap();
|
||||
let mut cols = 3;
|
||||
|
||||
// we want a total of n + 1 values
|
||||
|
@ -60,10 +60,10 @@ fn main() {
|
|||
// format the table
|
||||
let output = format!("({}, {}, {}),", x, modular_inverse(x), std::u64::MAX / x);
|
||||
if cols + output.len() > MAX_WIDTH {
|
||||
write!(file, "\n {}", output).unwrap();
|
||||
write!(file, "\n {output}").unwrap();
|
||||
cols = 4 + output.len();
|
||||
} else {
|
||||
write!(file, " {}", output).unwrap();
|
||||
write!(file, " {output}").unwrap();
|
||||
cols += 1 + output.len();
|
||||
}
|
||||
|
||||
|
@ -72,8 +72,7 @@ fn main() {
|
|||
|
||||
write!(
|
||||
file,
|
||||
"\n];\n\n#[allow(dead_code)]\npub const NEXT_PRIME: u64 = {};\n",
|
||||
x
|
||||
"\n];\n\n#[allow(dead_code)]\npub const NEXT_PRIME: u64 = {x};\n"
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ impl fmt::Display for Factors {
|
|||
|
||||
for (p, exp) in v.iter() {
|
||||
for _ in 0..*exp {
|
||||
write!(f, " {}", p)?;
|
||||
write!(f, " {p}")?;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -153,8 +153,7 @@ mod tests {
|
|||
for p in odd_primes() {
|
||||
assert!(
|
||||
test(Montgomery::<A>::new(p)).is_prime(),
|
||||
"{} reported composite",
|
||||
p
|
||||
"{p} reported composite"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -173,7 +172,7 @@ mod tests {
|
|||
fn first_composites() {
|
||||
for (p, q) in primes().zip(odd_primes()) {
|
||||
for i in p + 1..q {
|
||||
assert!(!is_prime(i), "{} reported prime", i);
|
||||
assert!(!is_prime(i), "{i} reported prime");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -192,7 +191,7 @@ mod tests {
|
|||
for q in odd_primes().take_while(|q| *q <= p) {
|
||||
let n = p * q;
|
||||
let m = Montgomery::<A>::new(n);
|
||||
assert!(!test(m).is_prime(), "{} = {} × {} reported prime", n, p, q);
|
||||
assert!(!test(m).is_prime(), "{n} = {p} × {q} reported prime");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,8 +32,8 @@ pub fn gcd(mut u: u64, mut v: u64) -> u64 {
|
|||
|
||||
loop {
|
||||
// Loop invariant: u and v are odd
|
||||
debug_assert!(u % 2 == 1, "u = {} is even", u);
|
||||
debug_assert!(v % 2 == 1, "v = {} is even", v);
|
||||
debug_assert!(u % 2 == 1, "u = {u} is even");
|
||||
debug_assert!(v % 2 == 1, "v = {v} is even");
|
||||
|
||||
// gcd(u, v) = gcd(|u - v|, min(u, v))
|
||||
if u > v {
|
||||
|
|
|
@ -13,7 +13,7 @@ use super::traits::Int;
|
|||
pub(crate) fn modular_inverse<T: Int>(a: T) -> T {
|
||||
let zero = T::zero();
|
||||
let one = T::one();
|
||||
debug_assert!(a % (one + one) == one, "{:?} is not odd", a);
|
||||
debug_assert!(a % (one + one) == one, "{a:?} is not odd");
|
||||
|
||||
let mut t = zero;
|
||||
let mut new_t = one;
|
||||
|
|
|
@ -192,7 +192,7 @@ mod tests {
|
|||
let m_x = m.to_mod(x);
|
||||
for y in 0..=x {
|
||||
let m_y = m.to_mod(y);
|
||||
println!("{n:?}, {x:?}, {y:?}", n = n, x = x, y = y);
|
||||
println!("{n:?}, {x:?}, {y:?}");
|
||||
assert_eq!((x + y) % n, m.to_u64(m.add(m_x, m_y)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ struct BreakArgs<'a> {
|
|||
}
|
||||
|
||||
impl<'a> BreakArgs<'a> {
|
||||
fn compute_width<'b>(&self, winfo: &WordInfo<'b>, posn: usize, fresh: bool) -> usize {
|
||||
fn compute_width(&self, winfo: &WordInfo, posn: usize, fresh: bool) -> usize {
|
||||
if fresh {
|
||||
0
|
||||
} else {
|
||||
|
|
|
@ -188,9 +188,9 @@ fn fold_file_bytewise<T: Read>(mut file: BufReader<T>, spaces: bool, width: usiz
|
|||
let at_eol = i >= len;
|
||||
|
||||
if at_eol {
|
||||
print!("{}", slice);
|
||||
print!("{slice}");
|
||||
} else {
|
||||
println!("{}", slice);
|
||||
println!("{slice}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -285,7 +285,7 @@ fn fold_file<T: Read>(mut file: BufReader<T>, spaces: bool, width: usize) -> URe
|
|||
}
|
||||
|
||||
if !output.is_empty() {
|
||||
print!("{}", output);
|
||||
print!("{output}");
|
||||
output.truncate(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ impl Display for GroupsError {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::GetGroupsFailed => write!(f, "failed to fetch groups"),
|
||||
Self::GroupNotFound(gid) => write!(f, "cannot find name for group ID {}", gid),
|
||||
Self::GroupNotFound(gid) => write!(f, "cannot find name for group ID {gid}"),
|
||||
Self::UserNotFound(user) => write!(f, "{}: no such user", user.quote()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -520,13 +520,12 @@ where
|
|||
// where `n` is the number of bytes.
|
||||
let bytes = options.digest.output_bits() / 4;
|
||||
let modifier = if bytes > 0 {
|
||||
format!("{{{}}}", bytes)
|
||||
format!("{{{bytes}}}")
|
||||
} else {
|
||||
"+".to_string()
|
||||
};
|
||||
let gnu_re = Regex::new(&format!(
|
||||
r"^(?P<digest>[a-fA-F0-9]{}) (?P<binary>[ \*])(?P<fileName>.*)",
|
||||
modifier,
|
||||
r"^(?P<digest>[a-fA-F0-9]{modifier}) (?P<binary>[ \*])(?P<fileName>.*)",
|
||||
))
|
||||
.map_err(|_| HashsumError::InvalidRegex)?;
|
||||
let bsd_re = Regex::new(&format!(
|
||||
|
@ -579,7 +578,7 @@ where
|
|||
uucore::util_name(),
|
||||
ck_filename
|
||||
);
|
||||
println!("{}: FAILED open or read", ck_filename);
|
||||
println!("{ck_filename}: FAILED open or read");
|
||||
continue;
|
||||
}
|
||||
Ok(file) => file,
|
||||
|
@ -604,11 +603,11 @@ where
|
|||
// easier (and more important) on Unix than on Windows.
|
||||
if sum == real_sum {
|
||||
if !options.quiet {
|
||||
println!("{}: OK", ck_filename);
|
||||
println!("{ck_filename}: OK");
|
||||
}
|
||||
} else {
|
||||
if !options.status {
|
||||
println!("{}: FAILED", ck_filename);
|
||||
println!("{ck_filename}: FAILED");
|
||||
}
|
||||
failed_cksum += 1;
|
||||
}
|
||||
|
@ -624,7 +623,7 @@ where
|
|||
if options.tag {
|
||||
println!("{} ({}) = {}", options.algoname, filename.display(), sum);
|
||||
} else if options.nonames {
|
||||
println!("{}", sum);
|
||||
println!("{sum}");
|
||||
} else {
|
||||
println!("{} {}{}", sum, binary_marker, filename.display());
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ impl Mode {
|
|||
fn from(matches: &ArgMatches) -> Result<Self, String> {
|
||||
if let Some(v) = matches.get_one::<String>(options::BYTES_NAME) {
|
||||
let (n, all_but_last) =
|
||||
parse::parse_num(v).map_err(|err| format!("invalid number of bytes: {}", err))?;
|
||||
parse::parse_num(v).map_err(|err| format!("invalid number of bytes: {err}"))?;
|
||||
if all_but_last {
|
||||
Ok(Self::AllButLastBytes(n))
|
||||
} else {
|
||||
|
@ -142,7 +142,7 @@ impl Mode {
|
|||
}
|
||||
} else if let Some(v) = matches.get_one::<String>(options::LINES_NAME) {
|
||||
let (n, all_but_last) =
|
||||
parse::parse_num(v).map_err(|err| format!("invalid number of lines: {}", err))?;
|
||||
parse::parse_num(v).map_err(|err| format!("invalid number of lines: {err}"))?;
|
||||
if all_but_last {
|
||||
Ok(Self::AllButLastLines(n))
|
||||
} else {
|
||||
|
@ -387,13 +387,13 @@ where
|
|||
}
|
||||
// if it were just `n`,
|
||||
if lines == n + 1 {
|
||||
input.seek(SeekFrom::Start(0))?;
|
||||
input.rewind()?;
|
||||
return Ok(size - i);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
if size - i == 0 {
|
||||
input.seek(SeekFrom::Start(0))?;
|
||||
input.rewind()?;
|
||||
return Ok(0);
|
||||
}
|
||||
}
|
||||
|
@ -459,7 +459,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
|||
if let Err(e) = usize::try_from(n) {
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
format!("{}: number of bytes is too large", e)
|
||||
format!("{e}: number of bytes is too large")
|
||||
));
|
||||
continue;
|
||||
};
|
||||
|
@ -493,7 +493,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
|||
if !first {
|
||||
println!();
|
||||
}
|
||||
println!("==> {} <==", name);
|
||||
println!("==> {name} <==");
|
||||
}
|
||||
head_file(&mut file, options)
|
||||
}
|
||||
|
@ -506,7 +506,7 @@ fn uu_head(options: &HeadOptions) -> UResult<()> {
|
|||
};
|
||||
show!(USimpleError::new(
|
||||
1,
|
||||
format!("error reading {}: Input/output error", name)
|
||||
format!("error reading {name}: Input/output error")
|
||||
));
|
||||
}
|
||||
first = false;
|
||||
|
|
|
@ -79,10 +79,10 @@ pub fn parse_obsolete(src: &str) -> Option<Result<impl Iterator<Item = OsString>
|
|||
Some(n) => n,
|
||||
None => return Some(Err(ParseError::Overflow)),
|
||||
};
|
||||
options.push(OsString::from(format!("{}", num)));
|
||||
options.push(OsString::from(format!("{num}")));
|
||||
} else {
|
||||
options.push(OsString::from("-n"));
|
||||
options.push(OsString::from(format!("{}", num)));
|
||||
options.push(OsString::from(format!("{num}")));
|
||||
}
|
||||
Some(Ok(options.into_iter()))
|
||||
}
|
||||
|
|
|
@ -50,5 +50,5 @@ fn hostid() {
|
|||
let mask = 0xffff_ffff;
|
||||
|
||||
result &= mask;
|
||||
println!("{:0>8x}", result);
|
||||
println!("{result:0>8x}");
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ fn display_hostname(matches: &ArgMatches) -> UResult<()> {
|
|||
}
|
||||
}
|
||||
|
||||
println!("{}", hostname);
|
||||
println!("{hostname}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -326,7 +326,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
if default_format {
|
||||
id_print(&mut state, &groups);
|
||||
}
|
||||
print!("{}", line_ending);
|
||||
print!("{line_ending}");
|
||||
|
||||
if i + 1 >= users.len() {
|
||||
break;
|
||||
|
@ -468,11 +468,11 @@ fn pretty(possible_pw: Option<Passwd>) {
|
|||
let rid = getuid();
|
||||
if let Ok(p) = Passwd::locate(rid) {
|
||||
if login == p.name {
|
||||
println!("login\t{}", login);
|
||||
println!("login\t{login}");
|
||||
}
|
||||
println!("uid\t{}", p.name);
|
||||
} else {
|
||||
println!("uid\t{}", rid);
|
||||
println!("uid\t{rid}");
|
||||
}
|
||||
|
||||
let eid = getegid();
|
||||
|
@ -480,7 +480,7 @@ fn pretty(possible_pw: Option<Passwd>) {
|
|||
if let Ok(p) = Passwd::locate(eid) {
|
||||
println!("euid\t{}", p.name);
|
||||
} else {
|
||||
println!("euid\t{}", eid);
|
||||
println!("euid\t{eid}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -489,7 +489,7 @@ fn pretty(possible_pw: Option<Passwd>) {
|
|||
if let Ok(g) = Group::locate(rid) {
|
||||
println!("euid\t{}", g.name);
|
||||
} else {
|
||||
println!("euid\t{}", rid);
|
||||
println!("euid\t{rid}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ impl Error for InstallError {}
|
|||
impl Display for InstallError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Unimplemented(opt) => write!(f, "Unimplemented feature: {}", opt),
|
||||
Self::Unimplemented(opt) => write!(f, "Unimplemented feature: {opt}"),
|
||||
Self::DirNeedsArg() => {
|
||||
write!(
|
||||
f,
|
||||
|
@ -115,7 +115,7 @@ impl Display for InstallError {
|
|||
&uio_error!(e, "cannot install {} to {}", from.quote(), to.quote()),
|
||||
f,
|
||||
),
|
||||
Self::StripProgramFailed(msg) => write!(f, "strip program failed: {}", msg),
|
||||
Self::StripProgramFailed(msg) => write!(f, "strip program failed: {msg}"),
|
||||
Self::MetadataFailed(e) => Display::fmt(&uio_error!(e, ""), f),
|
||||
Self::NoSuchUser(user) => write!(f, "no such user: {}", user.maybe_quote()),
|
||||
Self::NoSuchGroup(group) => write!(f, "no such group: {}", group.maybe_quote()),
|
||||
|
|
|
@ -41,7 +41,7 @@ impl Error for JoinError {}
|
|||
impl Display for JoinError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::IOError(e) => write!(f, "io error: {}", e),
|
||||
Self::IOError(e) => write!(f, "io error: {e}"),
|
||||
Self::UnorderedInput(e) => f.write_str(e),
|
||||
}
|
||||
}
|
||||
|
@ -692,7 +692,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
match exec(file1, file2, settings) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(USimpleError::new(1, format!("{}", e))),
|
||||
Err(e) => Err(USimpleError::new(1, format!("{e}"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -146,11 +146,11 @@ fn table() {
|
|||
|
||||
fn print_signal(signal_name_or_value: &str) -> UResult<()> {
|
||||
for (value, &signal) in ALL_SIGNALS.iter().enumerate() {
|
||||
if signal == signal_name_or_value || (format!("SIG{}", signal)) == signal_name_or_value {
|
||||
println!("{}", value);
|
||||
if signal == signal_name_or_value || (format!("SIG{signal}")) == signal_name_or_value {
|
||||
println!("{value}");
|
||||
return Ok(());
|
||||
} else if signal_name_or_value == value.to_string() {
|
||||
println!("{}", signal);
|
||||
println!("{signal}");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ fn print_signals() {
|
|||
if idx > 0 {
|
||||
print!(" ");
|
||||
}
|
||||
print!("{}", signal);
|
||||
print!("{signal}");
|
||||
}
|
||||
println!();
|
||||
}
|
||||
|
@ -205,7 +205,7 @@ fn kill(sig: Signal, pids: &[i32]) {
|
|||
for &pid in pids {
|
||||
if let Err(e) = signal::kill(Pid::from_raw(pid), sig) {
|
||||
show!(Error::from_raw_os_error(e as i32)
|
||||
.map_err_context(|| format!("sending signal to {} failed", pid)));
|
||||
.map_err_context(|| format!("sending signal to {pid} failed")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -466,7 +466,7 @@ fn simple_backup_path(path: &Path, suffix: &str) -> PathBuf {
|
|||
fn numbered_backup_path(path: &Path) -> PathBuf {
|
||||
let mut i: u64 = 1;
|
||||
loop {
|
||||
let new_path = simple_backup_path(path, &format!(".~{}~", i));
|
||||
let new_path = simple_backup_path(path, &format!(".~{i}~"));
|
||||
if !new_path.exists() {
|
||||
return new_path;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let _ = uu_app().try_get_matches_from(args)?;
|
||||
|
||||
match get_userlogin() {
|
||||
Some(userlogin) => println!("{}", userlogin),
|
||||
Some(userlogin) => println!("{userlogin}"),
|
||||
None => show_error!("no login name"),
|
||||
}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ impl Display for LsError {
|
|||
)
|
||||
}
|
||||
Self::InvalidLineWidth(s) => write!(f, "invalid line width: {}", s.quote()),
|
||||
Self::IOError(e) => write!(f, "general io error: {}", e),
|
||||
Self::IOError(e) => write!(f, "general io error: {e}"),
|
||||
Self::IOErrorContext(e, p, _) => {
|
||||
let error_kind = e.kind();
|
||||
let errno = e.raw_os_error().unwrap_or(1i32);
|
||||
|
@ -2067,11 +2067,11 @@ fn display_dir_entry_size(
|
|||
}
|
||||
|
||||
fn pad_left(string: &str, count: usize) -> String {
|
||||
format!("{:>width$}", string, width = count)
|
||||
format!("{string:>count$}")
|
||||
}
|
||||
|
||||
fn pad_right(string: &str, count: usize) -> String {
|
||||
format!("{:<width$}", string, width = count)
|
||||
format!("{string:<count$}")
|
||||
}
|
||||
|
||||
fn display_total(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout>) -> UResult<()> {
|
||||
|
@ -2118,7 +2118,7 @@ fn display_additional_leading_info(
|
|||
};
|
||||
// extra space is insert to align the sizes, as needed for all formats, except for the comma format.
|
||||
if config.format == Format::Commas {
|
||||
write!(result, "{} ", s).unwrap();
|
||||
write!(result, "{s} ").unwrap();
|
||||
} else {
|
||||
write!(result, "{} ", pad_left(&s, padding.block_size)).unwrap();
|
||||
};
|
||||
|
@ -2139,13 +2139,13 @@ fn display_items(items: &[PathData], config: &Config, out: &mut BufWriter<Stdout
|
|||
if config.inode || config.alloc_size {
|
||||
let more_info =
|
||||
display_additional_leading_info(item, &padding_collection, config, out)?;
|
||||
write!(out, "{}", more_info)?;
|
||||
write!(out, "{more_info}")?;
|
||||
}
|
||||
#[cfg(not(unix))]
|
||||
if config.alloc_size {
|
||||
let more_info =
|
||||
display_additional_leading_info(item, &padding_collection, config, out)?;
|
||||
write!(out, "{}", more_info)?;
|
||||
write!(out, "{more_info}")?;
|
||||
}
|
||||
display_item_long(item, &padding_collection, config, out)?;
|
||||
}
|
||||
|
@ -2276,7 +2276,7 @@ fn display_grid(
|
|||
|
||||
match grid.fit_into_width(width as usize) {
|
||||
Some(output) => {
|
||||
write!(out, "{}", output)?;
|
||||
write!(out, "{output}")?;
|
||||
}
|
||||
// Width is too small for the grid, so we fit it in one column
|
||||
None => {
|
||||
|
@ -2440,7 +2440,7 @@ fn display_item_long(
|
|||
write!(
|
||||
out,
|
||||
"{}{} {}",
|
||||
format_args!("{}?????????", leading_char),
|
||||
format_args!("{leading_char}?????????"),
|
||||
if item.security_context.len() > 1 {
|
||||
// GNU `ls` uses a "." character to indicate a file with a security context,
|
||||
// but not other alternate access method.
|
||||
|
@ -2875,7 +2875,7 @@ fn display_file_name(
|
|||
} else {
|
||||
path.security_context.to_owned()
|
||||
};
|
||||
name = format!("{} {}", security_context, name);
|
||||
name = format!("{security_context} {name}");
|
||||
width += security_context.len() + 1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ fn get_mode(matches: &ArgMatches, mode_had_minus_prefix: bool) -> Result<u32, St
|
|||
} else {
|
||||
let cmode = if mode_had_minus_prefix {
|
||||
// clap parsing is finished, now put prefix back
|
||||
format!("-{}", mode)
|
||||
format!("-{mode}")
|
||||
} else {
|
||||
mode.to_string()
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let mode = match matches.get_one::<String>(options::MODE) {
|
||||
Some(m) => match usize::from_str_radix(m, 8) {
|
||||
Ok(m) => m,
|
||||
Err(e) => return Err(USimpleError::new(1, format!("invalid mode: {}", e))),
|
||||
Err(e) => return Err(USimpleError::new(1, format!("invalid mode: {e}"))),
|
||||
},
|
||||
None => 0o666,
|
||||
};
|
||||
|
|
|
@ -184,7 +184,7 @@ fn get_mode(matches: &ArgMatches) -> Result<mode_t, String> {
|
|||
match matches.get_one::<String>("mode") {
|
||||
None => Ok(MODE_RW_UGO),
|
||||
Some(str_mode) => uucore::mode::parse_mode(str_mode)
|
||||
.map_err(|e| format!("invalid mode ({})", e))
|
||||
.map_err(|e| format!("invalid mode ({e})"))
|
||||
.and_then(|mode| {
|
||||
if mode > 0o777 {
|
||||
Err("mode must specify only file permission bits".to_string())
|
||||
|
|
|
@ -313,7 +313,7 @@ impl Params {
|
|||
// the template is "XXXabc", then `suffix` is "abc.txt".
|
||||
let suffix_from_option = options.suffix.unwrap_or_default();
|
||||
let suffix_from_template = &options.template[j..];
|
||||
let suffix = format!("{}{}", suffix_from_template, suffix_from_option);
|
||||
let suffix = format!("{suffix_from_template}{suffix_from_option}");
|
||||
if suffix.contains(MAIN_SEPARATOR) {
|
||||
return Err(MkTempError::SuffixContainsDirSeparator(suffix));
|
||||
}
|
||||
|
|
|
@ -383,9 +383,7 @@ impl<'a> Pager<'a> {
|
|||
.take(self.content_rows.into());
|
||||
|
||||
for line in displayed_lines {
|
||||
stdout
|
||||
.write_all(format!("\r{}\n", line).as_bytes())
|
||||
.unwrap();
|
||||
stdout.write_all(format!("\r{line}\n").as_bytes()).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -399,15 +397,14 @@ impl<'a> Pager<'a> {
|
|||
)
|
||||
};
|
||||
|
||||
let status = format!("--More--({})", status_inner);
|
||||
let status = format!("--More--({status_inner})");
|
||||
|
||||
let banner = match (self.silent, wrong_key) {
|
||||
(true, Some(key)) => format!(
|
||||
"{} [Unknown key: '{}'. Press 'h' for instructions. (unimplemented)]",
|
||||
status, key
|
||||
"{status} [Unknown key: '{key}'. Press 'h' for instructions. (unimplemented)]"
|
||||
),
|
||||
(true, None) => format!("{}[Press space to continue, 'q' to quit.]", status),
|
||||
(false, Some(_)) => format!("{}{}", status, BELL),
|
||||
(true, None) => format!("{status}[Press space to continue, 'q' to quit.]"),
|
||||
(false, Some(_)) => format!("{status}{BELL}"),
|
||||
(false, None) => status,
|
||||
};
|
||||
|
||||
|
|
|
@ -22,22 +22,19 @@ impl UError for MvError {}
|
|||
impl Display for MvError {
|
||||
fn fmt(&self, f: &mut Formatter) -> Result {
|
||||
match self {
|
||||
Self::NoSuchFile(s) => write!(f, "cannot stat {}: No such file or directory", s),
|
||||
Self::SameFile(s, t) => write!(f, "{} and {} are the same file", s, t),
|
||||
Self::NoSuchFile(s) => write!(f, "cannot stat {s}: No such file or directory"),
|
||||
Self::SameFile(s, t) => write!(f, "{s} and {t} are the same file"),
|
||||
Self::SelfSubdirectory(s) => write!(
|
||||
f,
|
||||
"cannot move '{s}' to a subdirectory of itself, '{s}/{s}'",
|
||||
s = s
|
||||
"cannot move '{s}' to a subdirectory of itself, '{s}/{s}'"
|
||||
),
|
||||
Self::DirectoryToNonDirectory(t) => {
|
||||
write!(f, "cannot overwrite directory {} with non-directory", t)
|
||||
write!(f, "cannot overwrite directory {t} with non-directory")
|
||||
}
|
||||
Self::NonDirectoryToDirectory(s, t) => write!(
|
||||
f,
|
||||
"cannot overwrite non-directory {} with directory {}",
|
||||
t, s
|
||||
),
|
||||
Self::NotADirectory(t) => write!(f, "target {} is not a directory", t),
|
||||
Self::NonDirectoryToDirectory(s, t) => {
|
||||
write!(f, "cannot overwrite non-directory {t} with directory {s}")
|
||||
}
|
||||
Self::NotADirectory(t) => write!(f, "target {t} is not a directory"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -91,8 +91,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
app.error(
|
||||
ErrorKind::TooFewValues,
|
||||
format!(
|
||||
"The argument '<{}>...' requires at least 2 values, but only 1 was provided",
|
||||
ARG_FILES
|
||||
"The argument '<{ARG_FILES}>...' requires at least 2 values, but only 1 was provided"
|
||||
),
|
||||
)
|
||||
.exit();
|
||||
|
@ -310,7 +309,7 @@ fn exec(files: &[OsString], b: &Behavior) -> UResult<()> {
|
|||
)
|
||||
.into())
|
||||
} else {
|
||||
rename(source, target, b, None).map_err(|e| USimpleError::new(1, format!("{}", e)))
|
||||
rename(source, target, b, None).map_err(|e| USimpleError::new(1, format!("{e}")))
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
|
@ -473,9 +472,9 @@ fn rename(
|
|||
|
||||
match multi_progress {
|
||||
Some(pb) => pb.suspend(|| {
|
||||
println!("{}", message);
|
||||
println!("{message}");
|
||||
}),
|
||||
None => println!("{}", message),
|
||||
None => println!("{message}"),
|
||||
};
|
||||
}
|
||||
Ok(())
|
||||
|
@ -547,7 +546,7 @@ fn rename_with_fallback(
|
|||
io::ErrorKind::PermissionDenied,
|
||||
"Permission denied",
|
||||
)),
|
||||
_ => Err(io::Error::new(io::ErrorKind::Other, format!("{:?}", err))),
|
||||
_ => Err(io::Error::new(io::ErrorKind::Other, format!("{err:?}"))),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -137,14 +137,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
Err(e) => {
|
||||
return Err(USimpleError::new(
|
||||
125,
|
||||
format!("\"{}\" is not a valid number: {}", nstr, e),
|
||||
format!("\"{nstr}\" is not a valid number: {e}"),
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if !matches.contains_id(options::COMMAND) {
|
||||
println!("{}", niceness);
|
||||
println!("{niceness}");
|
||||
return Ok(());
|
||||
}
|
||||
10_i32
|
||||
|
|
|
@ -349,7 +349,7 @@ fn nl<T: Read>(reader: &mut BufReader<T>, settings: &Settings) -> UResult<()> {
|
|||
// want to print one in the first place, or it is a blank
|
||||
// line but we are still collecting more blank lines via
|
||||
// the option --join-blank-lines.
|
||||
println!("{}", line);
|
||||
println!("{line}");
|
||||
continue;
|
||||
}
|
||||
// If we make it here, then either we are printing a non-empty
|
||||
|
|
|
@ -65,7 +65,7 @@ impl Display for NohupError {
|
|||
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::CannotDetach => write!(f, "Cannot detach from console"),
|
||||
Self::CannotReplace(s, e) => write!(f, "Cannot replace {}: {}", s, e),
|
||||
Self::CannotReplace(s, e) => write!(f, "Cannot replace {s}: {e}"),
|
||||
Self::OpenFailed(_, e) => {
|
||||
write!(f, "failed to open {}: {}", NOHUP_OUT.quote(), e)
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
} else {
|
||||
cores -= ignore;
|
||||
}
|
||||
println!("{}", cores);
|
||||
println!("{cores}");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ impl Display for NumfmtError {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::IoError(s) | Self::IllegalArgument(s) | Self::FormattingError(s) => {
|
||||
write!(f, "{}", s)
|
||||
write!(f, "{s}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,13 +135,11 @@ fn remove_suffix(i: f64, s: Option<Suffix>, u: &Unit) -> Result<f64> {
|
|||
RawSuffix::Z => Ok(i * IEC_BASES[7]),
|
||||
RawSuffix::Y => Ok(i * IEC_BASES[8]),
|
||||
},
|
||||
(None, &Unit::Iec(true)) => Err(format!(
|
||||
"missing 'i' suffix in input: '{}' (e.g Ki/Mi/Gi)",
|
||||
i
|
||||
)),
|
||||
(None, &Unit::Iec(true)) => {
|
||||
Err(format!("missing 'i' suffix in input: '{i}' (e.g Ki/Mi/Gi)"))
|
||||
}
|
||||
(Some((raw_suffix, false)), &Unit::Iec(true)) => Err(format!(
|
||||
"missing 'i' suffix in input: '{}{:?}' (e.g Ki/Mi/Gi)",
|
||||
i, raw_suffix
|
||||
"missing 'i' suffix in input: '{i}{raw_suffix:?}' (e.g Ki/Mi/Gi)"
|
||||
)),
|
||||
(Some((raw_suffix, with_i)), &Unit::None) => Err(format!(
|
||||
"rejecting suffix in input: '{}{:?}{}' (consider using --from)",
|
||||
|
@ -320,7 +318,7 @@ fn format_string(
|
|||
|
||||
// bring back the suffix before applying padding
|
||||
let number_with_suffix = match &options.suffix {
|
||||
Some(suffix) => format!("{}{}", number, suffix),
|
||||
Some(suffix) => format!("{number}{suffix}"),
|
||||
None => number,
|
||||
};
|
||||
|
||||
|
@ -362,14 +360,14 @@ fn format_and_print_delimited(s: &str, options: &NumfmtOptions) -> Result<()> {
|
|||
|
||||
// print delimiter before second and subsequent fields
|
||||
if n > 1 {
|
||||
print!("{}", delimiter);
|
||||
print!("{delimiter}");
|
||||
}
|
||||
|
||||
if field_selected {
|
||||
print!("{}", format_string(field.trim_start(), options, None)?);
|
||||
} else {
|
||||
// print unselected field without conversion
|
||||
print!("{}", field);
|
||||
print!("{field}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +400,7 @@ fn format_and_print_whitespace(s: &str, options: &NumfmtOptions) -> Result<()> {
|
|||
print!("{}", format_string(field, options, implicit_padding)?);
|
||||
} else {
|
||||
// print unselected field without conversion
|
||||
print!("{}{}", prefix, field);
|
||||
print!("{prefix}{field}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ where
|
|||
for (idx, line) in lines.by_ref().enumerate() {
|
||||
match line {
|
||||
Ok(l) if idx < options.header => {
|
||||
println!("{}", l);
|
||||
println!("{l}");
|
||||
Ok(())
|
||||
}
|
||||
Ok(l) => match format_and_print(&l, options) {
|
||||
|
@ -403,8 +403,8 @@ mod tests {
|
|||
let mock_buffer = MockBuffer {};
|
||||
let result = handle_buffer(BufReader::new(mock_buffer), &get_valid_options())
|
||||
.expect_err("returned Ok after receiving IO error");
|
||||
let result_debug = format!("{:?}", result);
|
||||
let result_display = format!("{}", result);
|
||||
let result_debug = format!("{result:?}");
|
||||
let result_display = format!("{result}");
|
||||
assert_eq!(result_debug, "IoError(\"broken pipe\")");
|
||||
assert_eq!(result_display, "broken pipe");
|
||||
assert_eq!(result.code(), 1);
|
||||
|
@ -415,8 +415,8 @@ mod tests {
|
|||
let input_value = b"135\nhello";
|
||||
let result = handle_buffer(BufReader::new(&input_value[..]), &get_valid_options())
|
||||
.expect_err("returned Ok after receiving improperly formatted input");
|
||||
let result_debug = format!("{:?}", result);
|
||||
let result_display = format!("{}", result);
|
||||
let result_debug = format!("{result:?}");
|
||||
let result_display = format!("{result}");
|
||||
assert_eq!(
|
||||
result_debug,
|
||||
"FormattingError(\"invalid suffix in input: 'hello'\")"
|
||||
|
|
|
@ -128,9 +128,9 @@ impl FromStr for FormatOptions {
|
|||
|
||||
if iter.peek().is_none() {
|
||||
return if options.prefix == s {
|
||||
Err(format!("format '{}' has no % directive", s))
|
||||
Err(format!("format '{s}' has no % directive"))
|
||||
} else {
|
||||
Err(format!("format '{}' ends in %", s))
|
||||
Err(format!("format '{s}' ends in %"))
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -151,8 +151,7 @@ impl FromStr for FormatOptions {
|
|||
Some(c) if c.is_ascii_digit() => padding.push('-'),
|
||||
_ => {
|
||||
return Err(format!(
|
||||
"invalid format '{}', directive must be %[0]['][-][N][.][N]f",
|
||||
s
|
||||
"invalid format '{s}', directive must be %[0]['][-][N][.][N]f"
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +170,7 @@ impl FromStr for FormatOptions {
|
|||
if let Ok(p) = padding.parse() {
|
||||
options.padding = Some(p);
|
||||
} else {
|
||||
return Err(format!("invalid format '{}' (width overflow)", s));
|
||||
return Err(format!("invalid format '{s}' (width overflow)"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -179,7 +178,7 @@ impl FromStr for FormatOptions {
|
|||
iter.next();
|
||||
|
||||
if matches!(iter.peek(), Some(' ' | '+' | '-')) {
|
||||
return Err(format!("invalid precision in format '{}'", s));
|
||||
return Err(format!("invalid precision in format '{s}'"));
|
||||
}
|
||||
|
||||
while let Some(c) = iter.peek() {
|
||||
|
@ -195,7 +194,7 @@ impl FromStr for FormatOptions {
|
|||
if let Ok(p) = precision.parse() {
|
||||
options.precision = Some(p);
|
||||
} else {
|
||||
return Err(format!("invalid precision in format '{}'", s));
|
||||
return Err(format!("invalid precision in format '{s}'"));
|
||||
}
|
||||
} else {
|
||||
options.precision = Some(0);
|
||||
|
@ -206,8 +205,7 @@ impl FromStr for FormatOptions {
|
|||
iter.next();
|
||||
} else {
|
||||
return Err(format!(
|
||||
"invalid format '{}', directive must be %[0]['][-][N][.][N]f",
|
||||
s
|
||||
"invalid format '{s}', directive must be %[0]['][-][N][.][N]f"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -222,7 +220,7 @@ impl FromStr for FormatOptions {
|
|||
}
|
||||
iter.next();
|
||||
} else {
|
||||
return Err(format!("format '{}' has too many % directives", s));
|
||||
return Err(format!("format '{s}' has too many % directives"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,9 +22,9 @@ impl PartialEq for FormatWriter {
|
|||
use crate::formatteriteminfo::FormatWriter::*;
|
||||
|
||||
match (self, other) {
|
||||
(&IntWriter(ref a), &IntWriter(ref b)) => a == b,
|
||||
(&FloatWriter(ref a), &FloatWriter(ref b)) => a == b,
|
||||
(&MultibyteWriter(ref a), &MultibyteWriter(ref b)) => *a as usize == *b as usize,
|
||||
(IntWriter(a), IntWriter(b)) => a == b,
|
||||
(FloatWriter(a), FloatWriter(b)) => a == b,
|
||||
(MultibyteWriter(a), MultibyteWriter(b)) => *a as usize == *b as usize,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ impl<'a> MemoryDecoder<'a> {
|
|||
2 => u64::from(self.byte_order.read_u16(&self.data[start..start + 2])),
|
||||
4 => u64::from(self.byte_order.read_u32(&self.data[start..start + 4])),
|
||||
8 => self.byte_order.read_u64(&self.data[start..start + 8]),
|
||||
_ => panic!("Invalid byte_size: {}", byte_size),
|
||||
_ => panic!("Invalid byte_size: {byte_size}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ impl<'a> MemoryDecoder<'a> {
|
|||
)),
|
||||
4 => f64::from(self.byte_order.read_f32(&self.data[start..start + 4])),
|
||||
8 => self.byte_order.read_f64(&self.data[start..start + 8]),
|
||||
_ => panic!("Invalid byte_size: {}", byte_size),
|
||||
_ => panic!("Invalid byte_size: {byte_size}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ impl InputOffset {
|
|||
(Radix::Octal, None) => format!("{:07o}", self.byte_pos),
|
||||
(Radix::Octal, Some(l)) => format!("{:07o} ({:07o})", self.byte_pos, l),
|
||||
(Radix::NoPrefix, None) => String::new(),
|
||||
(Radix::NoPrefix, Some(l)) => format!("({:07o})", l),
|
||||
(Radix::NoPrefix, Some(l)) => format!("({l:07o})"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ impl OdOptions {
|
|||
_ => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("Invalid argument --endian={}", s),
|
||||
format!("Invalid argument --endian={s}"),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ impl OdOptions {
|
|||
let mut label: Option<u64> = None;
|
||||
|
||||
let parsed_input = parse_inputs(matches)
|
||||
.map_err(|e| USimpleError::new(1, format!("Invalid inputs: {}", e)))?;
|
||||
.map_err(|e| USimpleError::new(1, format!("Invalid inputs: {e}")))?;
|
||||
let input_strings = match parsed_input {
|
||||
CommandLineInputs::FileNames(v) => v,
|
||||
CommandLineInputs::FileAndOffset((f, s, l)) => {
|
||||
|
@ -173,7 +173,7 @@ impl OdOptions {
|
|||
if matches.value_source(options::WIDTH) == Some(ValueSource::CommandLine) {
|
||||
match parse_number_of_bytes(s) {
|
||||
Ok(n) => usize::try_from(n)
|
||||
.map_err(|_| USimpleError::new(1, format!("‘{}‘ is too large", s)))?,
|
||||
.map_err(|_| USimpleError::new(1, format!("‘{s}‘ is too large")))?,
|
||||
Err(e) => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
|
@ -625,15 +625,15 @@ fn print_bytes(prefix: &str, input_decoder: &MemoryDecoder, output_info: &Output
|
|||
}
|
||||
|
||||
if first {
|
||||
print!("{}", prefix); // print offset
|
||||
// if printing in multiple formats offset is printed only once
|
||||
print!("{prefix}"); // print offset
|
||||
// if printing in multiple formats offset is printed only once
|
||||
first = false;
|
||||
} else {
|
||||
// this takes the space of the file offset on subsequent
|
||||
// lines of multi-format rasters.
|
||||
print!("{:>width$}", "", width = prefix.chars().count());
|
||||
}
|
||||
println!("{}", output_text);
|
||||
println!("{output_text}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,8 @@ fn format_item_c(bytes: &[u8]) -> String {
|
|||
|
||||
if b & 0x80 == 0x00 {
|
||||
match C_CHARS.get(b as usize) {
|
||||
Some(s) => format!("{:>4}", s),
|
||||
None => format!("{:>4}", b),
|
||||
Some(s) => format!("{s:>4}"),
|
||||
None => format!("{b:>4}"),
|
||||
}
|
||||
} else if (b & 0xc0) == 0x80 {
|
||||
// second or subsequent octet of an utf-8 sequence
|
||||
|
@ -57,24 +57,24 @@ fn format_item_c(bytes: &[u8]) -> String {
|
|||
} else if ((b & 0xe0) == 0xc0) && (bytes.len() >= 2) {
|
||||
// start of a 2 octet utf-8 sequence
|
||||
match from_utf8(&bytes[0..2]) {
|
||||
Ok(s) => format!("{:>4}", s),
|
||||
Err(_) => format!(" {:03o}", b),
|
||||
Ok(s) => format!("{s:>4}"),
|
||||
Err(_) => format!(" {b:03o}"),
|
||||
}
|
||||
} else if ((b & 0xf0) == 0xe0) && (bytes.len() >= 3) {
|
||||
// start of a 3 octet utf-8 sequence
|
||||
match from_utf8(&bytes[0..3]) {
|
||||
Ok(s) => format!("{:>4}", s),
|
||||
Err(_) => format!(" {:03o}", b),
|
||||
Ok(s) => format!("{s:>4}"),
|
||||
Err(_) => format!(" {b:03o}"),
|
||||
}
|
||||
} else if ((b & 0xf8) == 0xf0) && (bytes.len() >= 4) {
|
||||
// start of a 4 octet utf-8 sequence
|
||||
match from_utf8(&bytes[0..4]) {
|
||||
Ok(s) => format!("{:>4}", s),
|
||||
Err(_) => format!(" {:03o}", b),
|
||||
Ok(s) => format!("{s:>4}"),
|
||||
Err(_) => format!(" {b:03o}"),
|
||||
}
|
||||
} else {
|
||||
// invalid utf-8
|
||||
format!(" {:03o}", b)
|
||||
format!(" {b:03o}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ fn format_flo32(f: f32) -> String {
|
|||
|
||||
if f.classify() == FpCategory::Subnormal {
|
||||
// subnormal numbers will be normal as f64, so will print with a wrong precision
|
||||
format!("{:width$e}", f) // subnormal numbers
|
||||
format!("{f:width$e}") // subnormal numbers
|
||||
} else {
|
||||
format_float(f64::from(f), width, precision)
|
||||
}
|
||||
|
@ -63,9 +63,9 @@ fn format_float(f: f64, width: usize, precision: usize) -> String {
|
|||
return format!("{:>width$}", "-0");
|
||||
}
|
||||
if f == 0.0 || !f.is_finite() {
|
||||
return format!("{:width$}", f);
|
||||
return format!("{f:width$}");
|
||||
}
|
||||
return format!("{:width$e}", f); // subnormal numbers
|
||||
return format!("{f:width$e}"); // subnormal numbers
|
||||
}
|
||||
|
||||
let mut l = f.abs().log10().floor() as i32;
|
||||
|
@ -79,7 +79,7 @@ fn format_float(f: f64, width: usize, precision: usize) -> String {
|
|||
if l >= 0 && l <= (precision as i32 - 1) {
|
||||
format!("{:width$.dec$}", f, dec = (precision - 1) - l as usize)
|
||||
} else if l == -1 {
|
||||
format!("{:width$.dec$}", f, dec = precision)
|
||||
format!("{f:width$.precision$}")
|
||||
} else {
|
||||
format!("{:width$.dec$e}", f, dec = precision - 1)
|
||||
}
|
||||
|
|
|
@ -132,10 +132,7 @@ fn check_basic(path: &[String]) -> bool {
|
|||
if total_len > POSIX_PATH_MAX {
|
||||
writeln!(
|
||||
std::io::stderr(),
|
||||
"limit {} exceeded by length {} of file name {}",
|
||||
POSIX_PATH_MAX,
|
||||
total_len,
|
||||
joined_path
|
||||
"limit {POSIX_PATH_MAX} exceeded by length {total_len} of file name {joined_path}"
|
||||
);
|
||||
return false;
|
||||
} else if total_len == 0 {
|
||||
|
@ -226,7 +223,7 @@ fn check_searchable(path: &str) -> bool {
|
|||
if e.kind() == ErrorKind::NotFound {
|
||||
true
|
||||
} else {
|
||||
writeln!(std::io::stderr(), "{}", e);
|
||||
writeln!(std::io::stderr(), "{e}");
|
||||
false
|
||||
}
|
||||
}
|
||||
|
|
|
@ -241,11 +241,11 @@ fn idle_string(when: i64) -> String {
|
|||
// less than 1day
|
||||
let hours = duration / (60 * 60);
|
||||
let minutes = (duration % (60 * 60)) / 60;
|
||||
format!("{:02}:{:02}", hours, minutes)
|
||||
format!("{hours:02}:{minutes:02}")
|
||||
} else {
|
||||
// more than 1day
|
||||
let days = duration / (24 * 3600);
|
||||
format!("{}d", days)
|
||||
format!("{days}d")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ impl Pinky {
|
|||
None
|
||||
};
|
||||
if let Some(fullname) = fullname {
|
||||
print!(" {:<19.19}", fullname);
|
||||
print!(" {fullname:<19.19}");
|
||||
} else {
|
||||
print!(" {:19}", " ???");
|
||||
}
|
||||
|
@ -324,7 +324,7 @@ impl Pinky {
|
|||
let mut s = ut.host();
|
||||
if self.include_where && !s.is_empty() {
|
||||
s = ut.canon_host()?;
|
||||
print!(" {}", s);
|
||||
print!(" {s}");
|
||||
}
|
||||
|
||||
println!();
|
||||
|
@ -363,15 +363,15 @@ impl Pinky {
|
|||
|
||||
fn long_pinky(&self) {
|
||||
for u in &self.names {
|
||||
print!("Login name: {:<28}In real life: ", u);
|
||||
print!("Login name: {u:<28}In real life: ");
|
||||
if let Ok(pw) = Passwd::locate(u.as_str()) {
|
||||
let fullname = gecos_to_fullname(&pw).unwrap_or_default();
|
||||
let user_dir = pw.user_dir.unwrap_or_default();
|
||||
let user_shell = pw.user_shell.unwrap_or_default();
|
||||
println!(" {}", fullname);
|
||||
println!(" {fullname}");
|
||||
if self.include_home_and_shell {
|
||||
print!("Directory: {:<29}", user_dir);
|
||||
println!("Shell: {}", user_shell);
|
||||
print!("Directory: {user_dir:<29}");
|
||||
println!("Shell: {user_shell}");
|
||||
}
|
||||
if self.include_project {
|
||||
let mut p = PathBuf::from(&user_dir);
|
||||
|
|
|
@ -491,7 +491,7 @@ fn recreate_arguments(args: &[String]) -> Vec<String> {
|
|||
|
||||
fn print_error(matches: &ArgMatches, err: &PrError) {
|
||||
if !matches.get_flag(options::NO_FILE_WARNINGS) {
|
||||
eprintln!("{}", err);
|
||||
eprintln!("{err}");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,7 +505,7 @@ fn parse_usize(matches: &ArgMatches, opt: &str) -> Option<Result<usize, PrError>
|
|||
};
|
||||
matches
|
||||
.get_one::<String>(opt)
|
||||
.map(|i| (i.to_string(), format!("-{}", opt)))
|
||||
.map(|i| (i.to_string(), format!("-{opt}")))
|
||||
.map(from_parse_error_to_pr_error)
|
||||
}
|
||||
|
||||
|
@ -668,8 +668,7 @@ fn build_options(
|
|||
if let Some(end_page) = end_page {
|
||||
if start_page > end_page {
|
||||
return Err(PrError::EncounteredErrors(format!(
|
||||
"invalid --pages argument '{}:{}'",
|
||||
start_page, end_page
|
||||
"invalid --pages argument '{start_page}:{end_page}'"
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
@ -1203,7 +1202,7 @@ fn get_formatted_line_number(opts: &OutputOptions, line_number: usize, index: us
|
|||
separator
|
||||
)
|
||||
} else {
|
||||
format!("{:>width$}{}", line_str, separator)
|
||||
format!("{line_str:>width$}{separator}")
|
||||
}
|
||||
} else {
|
||||
String::new()
|
||||
|
|
|
@ -35,7 +35,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
|
||||
if variables.is_empty() {
|
||||
for (env_var, value) in env::vars() {
|
||||
print!("{}={}{}", env_var, value, separator);
|
||||
print!("{env_var}={value}{separator}");
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
continue;
|
||||
}
|
||||
if let Ok(var) = env::var(env_var) {
|
||||
print!("{}{}", var, separator);
|
||||
print!("{var}{separator}");
|
||||
} else {
|
||||
error_found = true;
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ impl WordFilter {
|
|||
.unwrap()
|
||||
.into_iter()
|
||||
.map(|c| if REGEX_CHARCLASS.contains(c) {
|
||||
format!("\\{}", c)
|
||||
format!("\\{c}")
|
||||
} else {
|
||||
c.to_string()
|
||||
})
|
||||
|
@ -220,7 +220,7 @@ impl Display for PtxError {
|
|||
Self::DumbFormat => {
|
||||
write!(f, "There is no dumb format with GNU extensions disabled")
|
||||
}
|
||||
Self::NotImplemented(s) => write!(f, "{} not implemented yet", s),
|
||||
Self::NotImplemented(s) => write!(f, "{s} not implemented yet"),
|
||||
Self::ParseError(e) => e.fmt(f),
|
||||
}
|
||||
}
|
||||
|
@ -553,8 +553,8 @@ fn get_output_chunks(
|
|||
fn tex_mapper(x: char) -> String {
|
||||
match x {
|
||||
'\\' => "\\backslash{}".to_owned(),
|
||||
'$' | '%' | '#' | '&' | '_' => format!("\\{}", x),
|
||||
'}' | '{' => format!("$\\{}$", x),
|
||||
'$' | '%' | '#' | '&' | '_' => format!("\\{x}"),
|
||||
'}' | '{' => format!("$\\{x}$"),
|
||||
_ => x.to_string(),
|
||||
}
|
||||
}
|
||||
|
@ -696,7 +696,7 @@ fn write_traditional_output(
|
|||
return Err(PtxError::DumbFormat.into());
|
||||
}
|
||||
};
|
||||
writeln!(writer, "{}", output_line).map_err_context(String::new)?;
|
||||
writeln!(writer, "{output_line}").map_err_context(String::new)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -176,11 +176,11 @@ pub fn uu_app() -> Command {
|
|||
fn show(path: &Path, no_trailing_delimiter: bool, use_zero: bool) -> std::io::Result<()> {
|
||||
let path = path.to_str().unwrap();
|
||||
if no_trailing_delimiter {
|
||||
print!("{}", path);
|
||||
print!("{path}");
|
||||
} else if use_zero {
|
||||
print!("{}\0", path);
|
||||
print!("{path}\0");
|
||||
} else {
|
||||
println!("{}", path);
|
||||
println!("{path}");
|
||||
}
|
||||
stdout().flush()
|
||||
}
|
||||
|
|
|
@ -117,7 +117,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
val => {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("Invalid argument to interactive ({})", val),
|
||||
format!("Invalid argument to interactive ({val})"),
|
||||
))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,11 +77,11 @@ pub(crate) fn write_full_error<W>(writer: &mut W, err: &dyn std::error::Error) -
|
|||
where
|
||||
W: Write,
|
||||
{
|
||||
write!(writer, "{}", err)?;
|
||||
write!(writer, "{err}")?;
|
||||
let mut err = err;
|
||||
while let Some(source) = err.source() {
|
||||
err = source;
|
||||
write!(writer, ": {}", err)?;
|
||||
write!(writer, ": {err}")?;
|
||||
}
|
||||
write!(writer, ".")?;
|
||||
Ok(())
|
||||
|
|
|
@ -52,7 +52,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
match r.kind() {
|
||||
clap::error::ErrorKind::DisplayHelp
|
||||
| clap::error::ErrorKind::DisplayVersion => {
|
||||
println!("{}", r);
|
||||
println!("{r}");
|
||||
return Ok(());
|
||||
}
|
||||
_ => {}
|
||||
|
@ -60,7 +60,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
}
|
||||
return Err(UUsageError::new(
|
||||
error_exit_status::ANOTHER_ERROR,
|
||||
format!("{}", r),
|
||||
format!("{r}"),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
@ -264,7 +264,7 @@ fn print_current_context() -> Result<()> {
|
|||
|
||||
if let Some(context) = context {
|
||||
let context = context.as_ref().to_str()?;
|
||||
println!("{}", context);
|
||||
println!("{context}");
|
||||
} else {
|
||||
println!();
|
||||
}
|
||||
|
|
|
@ -214,7 +214,7 @@ fn write_value_float(
|
|||
} else {
|
||||
format!("{value:>0width$.precision$}")
|
||||
};
|
||||
write!(writer, "{}", value_as_str)
|
||||
write!(writer, "{value_as_str}")
|
||||
}
|
||||
|
||||
/// Write a big int formatted according to the given parameters.
|
||||
|
@ -232,11 +232,11 @@ fn write_value_int(
|
|||
format!("{value:>0width$}")
|
||||
}
|
||||
} else if *value == ExtendedBigInt::MinusZero && is_first_iteration {
|
||||
format!("-{}", value)
|
||||
format!("-{value}")
|
||||
} else {
|
||||
format!("{}", value)
|
||||
format!("{value}")
|
||||
};
|
||||
write!(writer, "{}", value_as_str)
|
||||
write!(writer, "{value_as_str}")
|
||||
}
|
||||
|
||||
// TODO `print_seq()` and `print_seq_integers()` are nearly identical,
|
||||
|
@ -260,7 +260,7 @@ fn print_seq(
|
|||
let mut is_first_iteration = true;
|
||||
while !done_printing(&value, &increment, &last) {
|
||||
if !is_first_iteration {
|
||||
write!(stdout, "{}", separator)?;
|
||||
write!(stdout, "{separator}")?;
|
||||
}
|
||||
// If there was an argument `-f FORMAT`, then use that format
|
||||
// template instead of the default formatting strategy.
|
||||
|
@ -276,7 +276,7 @@ fn print_seq(
|
|||
// strings.
|
||||
match format {
|
||||
Some(f) => {
|
||||
let s = format!("{}", value);
|
||||
let s = format!("{value}");
|
||||
if let Err(x) = printf(f, &[s]) {
|
||||
show!(x);
|
||||
exit(1);
|
||||
|
@ -295,7 +295,7 @@ fn print_seq(
|
|||
is_first_iteration = false;
|
||||
}
|
||||
if !is_first_iteration {
|
||||
write!(stdout, "{}", terminator)?;
|
||||
write!(stdout, "{terminator}")?;
|
||||
}
|
||||
stdout.flush()?;
|
||||
Ok(())
|
||||
|
@ -330,7 +330,7 @@ fn print_seq_integers(
|
|||
let mut is_first_iteration = true;
|
||||
while !done_printing(&value, &increment, &last) {
|
||||
if !is_first_iteration {
|
||||
write!(stdout, "{}", separator)?;
|
||||
write!(stdout, "{separator}")?;
|
||||
}
|
||||
// If there was an argument `-f FORMAT`, then use that format
|
||||
// template instead of the default formatting strategy.
|
||||
|
@ -341,7 +341,7 @@ fn print_seq_integers(
|
|||
// TODO See similar comment about formatting in `print_seq()`.
|
||||
match format {
|
||||
Some(f) => {
|
||||
let s = format!("{}", value);
|
||||
let s = format!("{value}");
|
||||
if let Err(x) = printf(f, &[s]) {
|
||||
show!(x);
|
||||
exit(1);
|
||||
|
@ -355,7 +355,7 @@ fn print_seq_integers(
|
|||
}
|
||||
|
||||
if !is_first_iteration {
|
||||
write!(stdout, "{}", terminator)?;
|
||||
write!(stdout, "{terminator}")?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ use std::fs;
|
|||
use std::fs::{File, OpenOptions};
|
||||
use std::io;
|
||||
use std::io::prelude::*;
|
||||
use std::io::SeekFrom;
|
||||
use std::path::{Path, PathBuf};
|
||||
use uucore::display::Quotable;
|
||||
use uucore::error::{FromIo, UResult, USimpleError, UUsageError};
|
||||
|
@ -424,7 +423,7 @@ fn pass_name(pass_type: PassType) -> String {
|
|||
let mut s: String = String::new();
|
||||
while s.len() < 6 {
|
||||
for b in bytes {
|
||||
let readable: String = format!("{:x}", b);
|
||||
let readable: String = format!("{b:x}");
|
||||
s.push_str(&readable);
|
||||
}
|
||||
}
|
||||
|
@ -560,7 +559,7 @@ fn do_pass<'a>(
|
|||
generator_type: PassType<'a>,
|
||||
given_file_size: Option<u64>,
|
||||
) -> Result<(), io::Error> {
|
||||
file.seek(SeekFrom::Start(0))?;
|
||||
file.rewind()?;
|
||||
|
||||
// Use the given size or the whole file if not specified
|
||||
let size: u64 = given_file_size.unwrap_or(get_file_size(path)?);
|
||||
|
|
|
@ -54,10 +54,7 @@ impl<R: Read> RngCore for ReadRng<R> {
|
|||
|
||||
fn fill_bytes(&mut self, dest: &mut [u8]) {
|
||||
self.try_fill_bytes(dest).unwrap_or_else(|err| {
|
||||
panic!(
|
||||
"reading random bytes from Read implementation failed; error: {}",
|
||||
err
|
||||
);
|
||||
panic!("reading random bytes from Read implementation failed; error: {err}");
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
shuf_bytes(&mut evec, options)?;
|
||||
}
|
||||
Mode::InputRange((b, e)) => {
|
||||
let rvec = (b..e).map(|x| format!("{}", x)).collect::<Vec<String>>();
|
||||
let rvec = (b..e).map(|x| format!("{x}")).collect::<Vec<String>>();
|
||||
let mut rvec = rvec.iter().map(String::as_bytes).collect::<Vec<&[u8]>>();
|
||||
shuf_bytes(&mut rvec, options)?;
|
||||
}
|
||||
|
|
|
@ -278,7 +278,7 @@ fn write<I: WriteableTmpFile>(
|
|||
tmp_file.finished_writing()
|
||||
}
|
||||
|
||||
fn write_lines<'a, T: Write>(lines: &[Line<'a>], writer: &mut T, separator: u8) {
|
||||
fn write_lines<T: Write>(lines: &[Line], writer: &mut T, separator: u8) {
|
||||
for s in lines {
|
||||
writer.write_all(s.line.as_bytes()).unwrap();
|
||||
writer.write_all(&[separator]).unwrap();
|
||||
|
|
|
@ -220,13 +220,13 @@ impl Display for SortError {
|
|||
write!(f, "failed to open temporary file: {}", strip_errno(error))
|
||||
}
|
||||
Self::CompressProgExecutionFailed { code } => {
|
||||
write!(f, "couldn't execute compress program: errno {}", code)
|
||||
write!(f, "couldn't execute compress program: errno {code}")
|
||||
}
|
||||
Self::CompressProgTerminatedAbnormally { prog } => {
|
||||
write!(f, "{} terminated abnormally", prog.quote())
|
||||
}
|
||||
Self::TmpDirCreationFailed => write!(f, "could not create temporary directory"),
|
||||
Self::Uft8Error { error } => write!(f, "{}", error),
|
||||
Self::Uft8Error { error } => write!(f, "{error}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,10 +351,7 @@ impl GlobalSettings {
|
|||
.parse(input.trim())?;
|
||||
|
||||
usize::try_from(size).map_err(|_| {
|
||||
ParseSizeError::SizeTooBig(format!(
|
||||
"Buffer size {} does not fit in address space",
|
||||
size
|
||||
))
|
||||
ParseSizeError::SizeTooBig(format!("Buffer size {size} does not fit in address space"))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -563,7 +560,7 @@ impl<'a> Line<'a> {
|
|||
// optimizations here.
|
||||
|
||||
let line = self.line.replace('\t', ">");
|
||||
writeln!(writer, "{}", line)?;
|
||||
writeln!(writer, "{line}")?;
|
||||
|
||||
let mut fields = vec![];
|
||||
tokenize(self.line, settings.separator, &mut fields);
|
||||
|
@ -866,7 +863,7 @@ impl FieldSelector {
|
|||
'R' => key_settings.set_sort_mode(SortMode::Random)?,
|
||||
'r' => key_settings.reverse = true,
|
||||
'V' => key_settings.set_sort_mode(SortMode::Version)?,
|
||||
c => return Err(format!("invalid option: '{}'", c)),
|
||||
c => return Err(format!("invalid option: '{c}'")),
|
||||
}
|
||||
}
|
||||
Ok(ignore_blanks)
|
||||
|
@ -942,7 +939,7 @@ impl FieldSelector {
|
|||
|
||||
/// Look up the range in the line that corresponds to this selector.
|
||||
/// If needs_fields returned false, tokens must be None.
|
||||
fn get_range<'a>(&self, line: &'a str, tokens: Option<&[Field]>) -> Range<usize> {
|
||||
fn get_range(&self, line: &str, tokens: Option<&[Field]>) -> Range<usize> {
|
||||
enum Resolution {
|
||||
// The start index of the resolved character, inclusive
|
||||
StartOfChar(usize),
|
||||
|
|
|
@ -56,7 +56,7 @@ impl TmpDirWrapper {
|
|||
}
|
||||
std::process::exit(2)
|
||||
})
|
||||
.map_err(|e| USimpleError::new(2, format!("failed to set up signal handler: {}", e)))
|
||||
.map_err(|e| USimpleError::new(2, format!("failed to set up signal handler: {e}")))
|
||||
}
|
||||
|
||||
pub fn next_file(&mut self) -> UResult<(File, PathBuf)> {
|
||||
|
|
|
@ -245,7 +245,7 @@ impl Display for FixedWidthNumber {
|
|||
.iter()
|
||||
.map(|d| map_digit(self.radix, *d))
|
||||
.collect();
|
||||
write!(f, "{}", digits)
|
||||
write!(f, "{digits}")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@ pub fn instantiate_current_writer(
|
|||
.map_err(|_| {
|
||||
Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("unable to open '{}'; aborting", filename),
|
||||
format!("unable to open '{filename}'; aborting"),
|
||||
)
|
||||
})?,
|
||||
) as Box<dyn Write>)),
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn instantiate_current_writer(
|
|||
.map_err(|_| {
|
||||
Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("'{}' would overwrite input; aborting", filename),
|
||||
format!("'{filename}' would overwrite input; aborting"),
|
||||
)
|
||||
})?,
|
||||
) as Box<dyn Write>))
|
||||
|
|
|
@ -58,8 +58,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
let matches = uu_app().try_get_matches_from(args)?;
|
||||
match Settings::from(&matches) {
|
||||
Ok(settings) => split(&settings),
|
||||
Err(e) if e.requires_usage() => Err(UUsageError::new(1, format!("{}", e))),
|
||||
Err(e) => Err(USimpleError::new(1, format!("{}", e))),
|
||||
Err(e) if e.requires_usage() => Err(UUsageError::new(1, format!("{e}"))),
|
||||
Err(e) => Err(USimpleError::new(1, format!("{e}"))),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -343,13 +343,13 @@ enum StrategyError {
|
|||
impl fmt::Display for StrategyError {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match self {
|
||||
Self::Lines(e) => write!(f, "invalid number of lines: {}", e),
|
||||
Self::Bytes(e) => write!(f, "invalid number of bytes: {}", e),
|
||||
Self::Lines(e) => write!(f, "invalid number of lines: {e}"),
|
||||
Self::Bytes(e) => write!(f, "invalid number of bytes: {e}"),
|
||||
Self::NumberType(NumberTypeError::NumberOfChunks(s)) => {
|
||||
write!(f, "invalid number of chunks: {}", s)
|
||||
write!(f, "invalid number of chunks: {s}")
|
||||
}
|
||||
Self::NumberType(NumberTypeError::ChunkNumber(s)) => {
|
||||
write!(f, "invalid chunk number: {}", s)
|
||||
write!(f, "invalid chunk number: {s}")
|
||||
}
|
||||
Self::MultipleWays => write!(f, "cannot split in more than one way"),
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ impl fmt::Display for SettingsError {
|
|||
match self {
|
||||
Self::Strategy(e) => e.fmt(f),
|
||||
Self::SuffixNotParsable(s) => write!(f, "invalid suffix length: {}", s.quote()),
|
||||
Self::SuffixTooSmall(i) => write!(f, "the suffix length needs to be at least {}", i),
|
||||
Self::SuffixTooSmall(i) => write!(f, "the suffix length needs to be at least {i}"),
|
||||
Self::SuffixContainsSeparator(s) => write!(
|
||||
f,
|
||||
"invalid suffix {}, contains directory separator",
|
||||
|
@ -487,8 +487,7 @@ impl fmt::Display for SettingsError {
|
|||
#[cfg(windows)]
|
||||
Self::NotSupported => write!(
|
||||
f,
|
||||
"{} is currently not supported in this platform",
|
||||
OPT_FILTER
|
||||
"{OPT_FILTER} is currently not supported in this platform"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -547,7 +546,7 @@ impl Settings {
|
|||
if platform::paths_refer_to_same_file(&self.input, filename) {
|
||||
return Err(io::Error::new(
|
||||
ErrorKind::Other,
|
||||
format!("'{}' would overwrite input; aborting", filename),
|
||||
format!("'{filename}' would overwrite input; aborting"),
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -1305,7 +1304,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
|||
// allowable filenames, we use `ErrorKind::Other` to
|
||||
// indicate that. A special error message needs to be
|
||||
// printed in that case.
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{}", e))),
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))),
|
||||
ErrorKind::BrokenPipe => Ok(()),
|
||||
_ => Err(uio_error!(e, "input/output error")),
|
||||
},
|
||||
|
@ -1324,7 +1323,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
|||
// allowable filenames, we use `ErrorKind::Other` to
|
||||
// indicate that. A special error message needs to be
|
||||
// printed in that case.
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{}", e))),
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))),
|
||||
ErrorKind::BrokenPipe => Ok(()),
|
||||
_ => Err(uio_error!(e, "input/output error")),
|
||||
},
|
||||
|
@ -1343,7 +1342,7 @@ fn split(settings: &Settings) -> UResult<()> {
|
|||
// allowable filenames, we use `ErrorKind::Other` to
|
||||
// indicate that. A special error message needs to be
|
||||
// printed in that case.
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{}", e))),
|
||||
ErrorKind::Other => Err(USimpleError::new(1, format!("{e}"))),
|
||||
ErrorKind::BrokenPipe => Ok(()),
|
||||
_ => Err(uio_error!(e, "input/output error")),
|
||||
},
|
||||
|
|
|
@ -535,7 +535,7 @@ impl Stater {
|
|||
|
||||
for t in tokens.iter() {
|
||||
match *t {
|
||||
Token::Char(c) => print!("{}", c),
|
||||
Token::Char(c) => print!("{c}"),
|
||||
Token::Directive {
|
||||
flag,
|
||||
width,
|
||||
|
@ -588,7 +588,7 @@ impl Stater {
|
|||
let dst = match fs::read_link(&file) {
|
||||
Ok(path) => path,
|
||||
Err(e) => {
|
||||
println!("{}", e);
|
||||
println!("{e}");
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
@ -668,7 +668,7 @@ impl Stater {
|
|||
|
||||
for t in tokens.iter() {
|
||||
match *t {
|
||||
Token::Char(c) => print!("{}", c),
|
||||
Token::Char(c) => print!("{c}"),
|
||||
Token::Directive {
|
||||
flag,
|
||||
width,
|
||||
|
|
|
@ -120,8 +120,7 @@ fn check_option(matches: &ArgMatches, name: &str) -> Result<BufferType, ProgramO
|
|||
|m| {
|
||||
Ok(BufferType::Size(m.try_into().map_err(|_| {
|
||||
ProgramOptionsError(format!(
|
||||
"invalid mode '{}': Value too large for defined data type",
|
||||
x
|
||||
"invalid mode '{x}': Value too large for defined data type"
|
||||
))
|
||||
})?))
|
||||
},
|
||||
|
|
|
@ -170,7 +170,7 @@ fn stty(opts: &Options) -> UResult<()> {
|
|||
if let ControlFlow::Break(false) = apply_setting(&mut termios, setting) {
|
||||
return Err(USimpleError::new(
|
||||
1,
|
||||
format!("invalid argument '{}'", setting),
|
||||
format!("invalid argument '{setting}'"),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> {
|
|||
target_os = "netbsd",
|
||||
target_os = "openbsd"
|
||||
))]
|
||||
print!("speed {} baud; ", speed);
|
||||
print!("speed {speed} baud; ");
|
||||
|
||||
// Other platforms need to use the baud rate enum, so printing the right value
|
||||
// becomes slightly more complicated.
|
||||
|
@ -209,7 +209,7 @@ fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> {
|
|||
)))]
|
||||
for (text, baud_rate) in BAUD_RATES {
|
||||
if *baud_rate == speed {
|
||||
print!("speed {} baud; ", text);
|
||||
print!("speed {text} baud; ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ fn print_terminal_size(termios: &Termios, opts: &Options) -> nix::Result<()> {
|
|||
// so we get the underlying libc::termios struct to get that information.
|
||||
let libc_termios: nix::libc::termios = termios.clone().into();
|
||||
let line = libc_termios.c_line;
|
||||
print!("line = {};", line);
|
||||
print!("line = {line};");
|
||||
}
|
||||
|
||||
println!();
|
||||
|
@ -258,14 +258,14 @@ fn print_flags<T: TermiosFlag>(termios: &Termios, opts: &Options, flags: &[Flag<
|
|||
let val = flag.is_in(termios, group);
|
||||
if group.is_some() {
|
||||
if val && (!sane || opts.all) {
|
||||
print!("{} ", name);
|
||||
print!("{name} ");
|
||||
printed = true;
|
||||
}
|
||||
} else if opts.all || val != sane {
|
||||
if !val {
|
||||
print!("-");
|
||||
}
|
||||
print!("{} ", name);
|
||||
print!("{name} ");
|
||||
printed = true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,9 +134,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
|||
};
|
||||
|
||||
if print_names {
|
||||
println!("{:0width$} {:width$} {}", sum, blocks, file);
|
||||
println!("{sum:0width$} {blocks:width$} {file}");
|
||||
} else {
|
||||
println!("{:0width$} {:width$}", sum, blocks);
|
||||
println!("{sum:0width$} {blocks:width$}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
|
|
@ -44,7 +44,7 @@ impl Error for TacError {}
|
|||
impl Display for TacError {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::InvalidRegex(e) => write!(f, "invalid regular expression: {}", e),
|
||||
Self::InvalidRegex(e) => write!(f, "invalid regular expression: {e}"),
|
||||
Self::InvalidArgument(s) => {
|
||||
write!(f, "{}: read error: Invalid argument", s.maybe_quote())
|
||||
}
|
||||
|
@ -53,8 +53,8 @@ impl Display for TacError {
|
|||
"failed to open {} for reading: No such file or directory",
|
||||
s.quote()
|
||||
),
|
||||
Self::ReadError(s, e) => write!(f, "failed to read from {}: {}", s, e),
|
||||
Self::WriteError(e) => write!(f, "failed to write to stdout: {}", e),
|
||||
Self::ReadError(s, e) => write!(f, "failed to read from {s}: {e}"),
|
||||
Self::WriteError(e) => write!(f, "failed to write to stdout: {e}"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -69,12 +69,7 @@ impl FilterMode {
|
|||
let mode = if let Some(arg) = matches.get_one::<String>(options::BYTES) {
|
||||
match parse_num(arg) {
|
||||
Ok(signum) => Self::Bytes(signum),
|
||||
Err(e) => {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
format!("invalid number of bytes: {}", e),
|
||||
))
|
||||
}
|
||||
Err(e) => return Err(UUsageError::new(1, format!("invalid number of bytes: {e}"))),
|
||||
}
|
||||
} else if let Some(arg) = matches.get_one::<String>(options::LINES) {
|
||||
match parse_num(arg) {
|
||||
|
@ -82,12 +77,7 @@ impl FilterMode {
|
|||
let delimiter = if zero_term { 0 } else { b'\n' };
|
||||
Self::Lines(signum, delimiter)
|
||||
}
|
||||
Err(e) => {
|
||||
return Err(UUsageError::new(
|
||||
1,
|
||||
format!("invalid number of lines: {}", e),
|
||||
))
|
||||
}
|
||||
Err(e) => return Err(UUsageError::new(1, format!("invalid number of lines: {e}"))),
|
||||
}
|
||||
} else if zero_term {
|
||||
Self::default_zero()
|
||||
|
|
|
@ -48,7 +48,7 @@ pub struct ReverseChunks<'a> {
|
|||
impl<'a> ReverseChunks<'a> {
|
||||
pub fn new(file: &'a mut File) -> ReverseChunks<'a> {
|
||||
let current = if cfg!(unix) {
|
||||
file.seek(SeekFrom::Current(0)).unwrap()
|
||||
file.stream_position().unwrap()
|
||||
} else {
|
||||
0
|
||||
};
|
||||
|
|
|
@ -566,11 +566,11 @@ pub fn follow(mut observer: Observer, settings: &Settings) -> UResult<()> {
|
|||
format!("{} resources exhausted", text::BACKEND),
|
||||
))
|
||||
}
|
||||
Ok(Err(e)) => return Err(USimpleError::new(1, format!("NotifyError: {}", e))),
|
||||
Ok(Err(e)) => return Err(USimpleError::new(1, format!("NotifyError: {e}"))),
|
||||
Err(mpsc::RecvTimeoutError::Timeout) => {
|
||||
_timeout_counter += 1;
|
||||
}
|
||||
Err(e) => return Err(USimpleError::new(1, format!("RecvTimeoutError: {}", e))),
|
||||
Err(e) => return Err(USimpleError::new(1, format!("RecvTimeoutError: {e}"))),
|
||||
}
|
||||
|
||||
if observer.use_polling && settings.follow.is_some() {
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue