Skip to content

der: Allow SetOf* duplicates#2272

Open
kraemv wants to merge 1 commit intoRustCrypto:masterfrom
kraemv:fix/set_of_duplicates
Open

der: Allow SetOf* duplicates#2272
kraemv wants to merge 1 commit intoRustCrypto:masterfrom
kraemv:fix/set_of_duplicates

Conversation

@kraemv
Copy link
Copy Markdown

@kraemv kraemv commented Apr 2, 2026

Hello everyone,

this PR addresses #2271 and disables checks for duplicate elements in SetOf* structs.
The main change is removing the check_duplicate function and changing the behavior for Ordering::Equal results.

I also changed the reject_duplicates tests to allow_duplicate tests that check if duplicates are valid.

I am happy to receive feedback on the changes!


/// Ensure set elements are lexicographically ordered using [`DerOrd`].
fn check_der_ordering<T: DerOrd>(a: &T, b: &T) -> Result<(), Error> {
match a.der_cmp(b)? {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably just change to:

Suggested change
match a.der_cmp(b)? {
if a.der_cmp(b)? == Ordering::Greater {

@@ -531,8 +510,7 @@ fn der_sort<T: DerOrd>(slice: &mut [T]) -> Result<(), Error> {

while j > 0 {
match slice[j - 1].der_cmp(&slice[j])? {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise this can probably switch to an if statement

@tarcieri
Copy link
Copy Markdown
Member

tarcieri commented Apr 2, 2026

@kraemv would you also mind adding a #[deprecated] attribute to ErrorKind::SetDuplicate? Thanks!

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