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

fixes suggested by nightly version of clippy

This commit is contained in:
Jeffrey Finkelstein 2021-12-26 15:45:33 -05:00
parent 4b4a83ac2e
commit f2bf1a7ff7
7 changed files with 22 additions and 23 deletions

View file

@ -18,7 +18,7 @@ pub fn main() {
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").unwrap();
// println!("cargo:warning=out_dir={}", out_dir); // println!("cargo:warning=out_dir={}", out_dir);
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap().replace("\\", "/"); let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap().replace('\\', "/");
// println!("cargo:warning=manifest_dir={}", manifest_dir); // println!("cargo:warning=manifest_dir={}", manifest_dir);
let util_tests_dir = format!("{}/tests/by-util", manifest_dir); let util_tests_dir = format!("{}/tests/by-util", manifest_dir);
// println!("cargo:warning=util_tests_dir={}", util_tests_dir); // println!("cargo:warning=util_tests_dir={}", util_tests_dir);

View file

@ -462,7 +462,7 @@ fn numbered_backup_path(path: &Path) -> PathBuf {
} }
fn existing_backup_path(path: &Path, suffix: &str) -> PathBuf { fn existing_backup_path(path: &Path, suffix: &str) -> PathBuf {
let test_path = simple_backup_path(path, &".~1~".to_owned()); let test_path = simple_backup_path(path, ".~1~");
if test_path.exists() { if test_path.exists() {
return numbered_backup_path(path); return numbered_backup_path(path);
} }

View file

@ -45,13 +45,13 @@ impl<'a> Iterator for WhitespaceSplitter<'a> {
let (prefix, field) = haystack.split_at( let (prefix, field) = haystack.split_at(
haystack haystack
.find(|c: char| !c.is_whitespace()) .find(|c: char| !c.is_whitespace())
.unwrap_or_else(|| haystack.len()), .unwrap_or(haystack.len()),
); );
let (field, rest) = field.split_at( let (field, rest) = field.split_at(
field field
.find(|c: char| c.is_whitespace()) .find(|c: char| c.is_whitespace())
.unwrap_or_else(|| field.len()), .unwrap_or(field.len()),
); );
self.s = if !rest.is_empty() { Some(rest) } else { None }; self.s = if !rest.is_empty() { Some(rest) } else { None };
@ -269,7 +269,7 @@ fn format_and_print_whitespace(s: &str, options: &NumfmtOptions) -> Result<()> {
print!(" "); print!(" ");
&prefix[1..] &prefix[1..]
} else { } else {
&prefix prefix
}; };
let implicit_padding = if !empty_prefix && options.padding == 0 { let implicit_padding = if !empty_prefix && options.padding == 0 {

View file

@ -151,5 +151,5 @@ fn unescape(s: String) -> String {
s.replace("\\n", "\n") s.replace("\\n", "\n")
.replace("\\t", "\t") .replace("\\t", "\t")
.replace("\\\\", "\\") .replace("\\\\", "\\")
.replace("\\", "") .replace('\\', "")
} }

View file

@ -916,8 +916,7 @@ fn read_stream_and_create_pages(
Box::new( Box::new(
lines lines
.map(split_lines_if_form_feed) .flat_map(split_lines_if_form_feed)
.flatten()
.enumerate() .enumerate()
.map(move |(i, line)| FileLine { .map(move |(i, line)| FileLine {
line_number: i + start_line_number, line_number: i + start_line_number,
@ -982,20 +981,18 @@ fn mpr(paths: &[String], options: &OutputOptions) -> Result<i32, PrError> {
.map(|(i, path)| { .map(|(i, path)| {
let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()).lines(); let lines = BufReader::with_capacity(READ_BUFFER_SIZE, open(path).unwrap()).lines();
read_stream_and_create_pages(options, lines, i) read_stream_and_create_pages(options, lines, i).flat_map(move |(x, line)| {
.map(move |(x, line)| { let file_line = line;
let file_line = line; let page_number = x + 1;
let page_number = x + 1; file_line
file_line .into_iter()
.into_iter() .map(|fl| FileLine {
.map(|fl| FileLine { page_number,
page_number, group_key: page_number * n_files + fl.file_id,
group_key: page_number * n_files + fl.file_id, ..fl
..fl })
}) .collect::<Vec<_>>()
.collect::<Vec<_>>() })
})
.flatten()
}) })
.kmerge_by(|a, b| { .kmerge_by(|a, b| {
if a.group_key == b.group_key { if a.group_key == b.group_key {

View file

@ -526,7 +526,7 @@ fn format_tex_line(
} }
fn format_roff_field(s: &str) -> String { fn format_roff_field(s: &str) -> String {
s.replace("\"", "\"\"") s.replace('\"', "\"\"")
} }
fn format_roff_line( fn format_roff_line(

View file

@ -125,11 +125,13 @@ impl<R: Read> Data<R> {
} }
} }
#[must_use]
pub fn line_wrap(mut self, wrap: usize) -> Self { pub fn line_wrap(mut self, wrap: usize) -> Self {
self.line_wrap = wrap; self.line_wrap = wrap;
self self
} }
#[must_use]
pub fn ignore_garbage(mut self, ignore: bool) -> Self { pub fn ignore_garbage(mut self, ignore: bool) -> Self {
self.ignore_garbage = ignore; self.ignore_garbage = ignore;
self self