Skip to content

refactor: replace manual last()+pop() patterns with Vec::pop_if#11272

Merged
sylvestre merged 1 commit intouutils:mainfrom
mattsu2020:pop_if
Mar 10, 2026
Merged

refactor: replace manual last()+pop() patterns with Vec::pop_if#11272
sylvestre merged 1 commit intouutils:mainfrom
mattsu2020:pop_if

Conversation

@mattsu2020
Copy link
Copy Markdown
Contributor

Summary

  • replace manual last() + pop() patterns with Vec::pop_if
  • simplify trailing-element removal in shuf, uniq, nl, dd, and paste
  • remove the redundant assert_eq!(output.pop(), ...) in paste

This is a small refactor enabled by the current MSRV and is not intended to change behavior.

…thod

Replace manual checks for last element existence and condition with the new pop_if() method for cleaner, more idiomatic code across multiple utilities (dd, nl, paste, shuf, uniq). This change improves code readability and reduces boilerplate while maintaining identical functionality.
@github-actions
Copy link
Copy Markdown

GNU testsuite comparison:

Skipping an intermittent issue tests/date/date-locale-hour (passes in this run but fails in the 'main' branch)
Congrats! The gnu test tests/rm/many-dir-entries-vs-OOM is now passing!
Congrats! The gnu test tests/seq/seq-epipe is now passing!
Note: The gnu test tests/env/env-signal-handler was skipped on 'main' but is now failing.

@sylvestre sylvestre merged commit f414b70 into uutils:main Mar 10, 2026
158 of 160 checks passed
@mattsu2020 mattsu2020 deleted the pop_if branch March 10, 2026 08:20
sylvestre pushed a commit to sylvestre/coreutils that referenced this pull request Mar 18, 2026
…thod (uutils#11272)

Replace manual checks for last element existence and condition with the new pop_if() method for cleaner, more idiomatic code across multiple utilities (dd, nl, paste, shuf, uniq). This change improves code readability and reduces boilerplate while maintaining identical functionality.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants