Skip to content

feat!: Use equivalent for Map and Set getters#153

Merged
jneem merged 1 commit intojneem:mainfrom
DanikVitek:equivalent
Feb 17, 2026
Merged

feat!: Use equivalent for Map and Set getters#153
jneem merged 1 commit intojneem:mainfrom
DanikVitek:equivalent

Conversation

@DanikVitek
Copy link
Contributor

Closes #152

Comment on lines 267 to +269
where
R: RangeBounds<BK>,
K: Borrow<BK>,
BK: Ord + ?Sized,
R: RangeBounds<Q>,
Q: Comparable<K> + ?Sized,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jneem unfortunately, the API for range now requires to sometimes specify the second type parameter, as it cannot be inferred. Can be seen in tests

Copy link
Owner

Choose a reason for hiding this comment

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

Huh, I'm a little surprised at that. Thanks for calling it out.

.collect();
assert_eq!(vec![(7, 8), (5, 6), (4, 5), (3, 4), (2, 3), (1, 2)], range);
let range: Vec<(i32, i32)> = map.range(&2..&5).map(|(k, v)| (*k, *v)).collect();
let range: Vec<(i32, i32)> = map.range(2..5).map(|(k, v)| (*k, *v)).collect();
Copy link
Owner

Choose a reason for hiding this comment

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

This change isn't actually necessary, right? I mean, I think it's a good change, but maybe leave just one Range<&i32> example, just to sanity-check that we're backwards compatible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, it's either this, or an explicit ::<_, i32> turbofish.
зображення

Comment on lines 267 to +269
where
R: RangeBounds<BK>,
K: Borrow<BK>,
BK: Ord + ?Sized,
R: RangeBounds<Q>,
Q: Comparable<K> + ?Sized,
Copy link
Owner

Choose a reason for hiding this comment

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

Huh, I'm a little surprised at that. Thanks for calling it out.

@jneem jneem merged commit 2eb281d into jneem:main Feb 17, 2026
19 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.

More flexible type bounds on getters

2 participants