mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-30 04:27:45 +00:00
refactor/polish ~ fix cargo clippy
complaints (skip_while_next)
This commit is contained in:
parent
0cf704a1bf
commit
9675addc50
4 changed files with 5 additions and 8 deletions
|
@ -146,7 +146,7 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> usize {
|
|||
if tabstops.len() == 1 {
|
||||
tabstops[0] - col % tabstops[0]
|
||||
} else {
|
||||
match tabstops.iter().skip_while(|&&t| t <= col).next() {
|
||||
match tabstops.iter().find(|&&t| t > col) {
|
||||
Some(t) => t - col,
|
||||
None => 1,
|
||||
}
|
||||
|
|
|
@ -416,8 +416,7 @@ fn simple_backup_path(path: &PathBuf, suffix: &str) -> PathBuf {
|
|||
fn numbered_backup_path(path: &PathBuf) -> PathBuf {
|
||||
(1_u64..)
|
||||
.map(|i| path.with_extension(format!("~{}~", i)))
|
||||
.skip_while(|p| p.exists())
|
||||
.next()
|
||||
.find(|p| !p.exists())
|
||||
.expect("cannot create backup")
|
||||
}
|
||||
|
||||
|
|
|
@ -411,10 +411,8 @@ fn numeric_compare(a: &str, b: &str) -> Ordering {
|
|||
}
|
||||
|
||||
fn human_numeric_convert(a: &str) -> f64 {
|
||||
let int_iter = a.chars();
|
||||
let suffix_iter = a.chars();
|
||||
let int_str: String = int_iter.take_while(|c| c.is_numeric()).collect();
|
||||
let suffix = suffix_iter.skip_while(|c| c.is_numeric()).next();
|
||||
let int_str: String = a.chars().take_while(|c| c.is_numeric()).collect();
|
||||
let suffix = a.chars().find(|c| !c.is_numeric());
|
||||
let int_part = match int_str.parse::<f64>() {
|
||||
Ok(i) => i,
|
||||
Err(_) => -1f64,
|
||||
|
|
|
@ -164,7 +164,7 @@ fn next_tabstop(tabstops: &[usize], col: usize) -> Option<usize> {
|
|||
Some(tabstops[0] - col % tabstops[0])
|
||||
} else {
|
||||
// find next larger tab
|
||||
match tabstops.iter().skip_while(|&&t| t <= col).next() {
|
||||
match tabstops.iter().find(|&&t| t > col) {
|
||||
Some(t) => Some(t - col),
|
||||
None => None, // if there isn't one in the list, tab becomes a single space
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue