Skip to content

Conversation

@liwenjieQu
Copy link
Contributor

This PR adds support for the Equivalent trait to enable flexible key lookups in both PriorityQueue and DoublePriorityQueue.

Background

The underlying IndexMap uses the Equivalent trait as the boundary for input types in lookup operations. This PR updates the trait bounds for priority queue APIs to align with this requirement, replacing the previous Borrow<Q> pattern.

Changes

  • Updated method signatures for lookup operations (get_priority, contains, change_priority, get, get_mut, remove) to use Equivalent<I> trait bounds
  • Added comprehensive tests covering both blanket implementations and custom equivalent types

Backward Compatibility

This change maintains full backward compatibility. Existing code that satisfied the previous trait bound:

I: Borrow<Q>,
Q: Eq + Hash + ?Sized,

continues to work without modification thanks to the blanket implementation provided by the equivalent crate. Users can now implement custom Equivalent traits for flexible key lookups.

@garro95 garro95 merged commit e313628 into garro95:master Sep 5, 2025
14 checks passed
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