Repository navigation
uniq: simplify matches - #16935
Merged
Merged
uniq: simplify matches#16935
Conversation
cakebaker
approved these changes
Nov 28, 2026
xtqqczze
reviewed
Nov 28, 2026
| // following slice should be treaded as value for this option | ||
| // even if it starts with '-' (which would be treated as hyphen prefixed value) | ||
| if slice.starts_with("--") { | ||
| if let Some(opt) = slice.strip_prefix("--") { |
Collaborator
There was a problem hiding this comment.
the commit description says "simplify matches" but this is an unrelated improvement?
Contributor
Author
There was a problem hiding this comment.
I intended to matches!(opt, O::SKIP_CHARS | O::SKIP_FIELDS | O::CHECK_CHARS) (which does not compile and contains is used).
Collaborator
There was a problem hiding this comment.
This change would ideally deserve its own commit, though it’s fine to keep it in this PR.
Collaborator
There was a problem hiding this comment.
Yeah matches! doesn't work here because these are statics not constants:
error[E0532]: expected unit struct, unit variant or constant, found static `options::SKIP_CHARS`
--> src/uu/uniq/src/uniq.rs:520:13
|
520 | options::SKIP_CHARS | options::SKIP_FIELDS | options::CHECK_CHARSI wonder if we can change static to const:
pub mod options {
pub const ALL_REPEATED: &str = "all-repeated";
...
}
Contributor
There was a problem hiding this comment.
Yes, that's possible. I think we already have utils that use const for the options.
Contributor
|
Thanks for your PR |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#16927 (comment)