1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 11:07:44 +00:00
Ben Wiederhake 2025-04-13 04:05:56 +02:00
parent fc3f7eaa48
commit 875770f5d1
3 changed files with 3 additions and 5 deletions

View file

@ -82,7 +82,7 @@ fn get_local_to_root_parent(
/// Given an iterator, return all its items except the last. /// Given an iterator, return all its items except the last.
fn skip_last<T>(mut iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> { fn skip_last<T>(mut iter: impl Iterator<Item = T>) -> impl Iterator<Item = T> {
let last = iter.next(); let last = iter.next();
iter.scan(last, |state, item| std::mem::replace(state, Some(item))) iter.scan(last, |state, item| state.replace(item))
} }
/// Paths that are invariant throughout the traversal when copying a directory. /// Paths that are invariant throughout the traversal when copying a directory.

View file

@ -164,9 +164,7 @@ fn break_knuth_plass<'a, T: Clone + Iterator<Item = &'a WordInfo<'a>>>(
// We find identical breakpoints here by comparing addresses of the references. // We find identical breakpoints here by comparing addresses of the references.
// This is OK because the backing vector is not mutating once we are linebreaking. // This is OK because the backing vector is not mutating once we are linebreaking.
let winfo_ptr = winfo as *const _; if std::ptr::eq(winfo, next_break) {
let next_break_ptr = next_break as *const _;
if winfo_ptr == next_break_ptr {
// OK, we found the matching word // OK, we found the matching word
if break_before { if break_before {
write_newline(args.indent_str, args.ostream)?; write_newline(args.indent_str, args.ostream)?;

View file

@ -55,7 +55,7 @@ fn tabstops_parse(s: &str) -> Result<Vec<usize>, ParseError> {
} }
} }
if nums.iter().any(|&n| n == 0) { if nums.contains(&0) {
return Err(ParseError::TabSizeCannotBeZero); return Err(ParseError::TabSizeCannotBeZero);
} }