-
Notifications
You must be signed in to change notification settings - Fork 1
Add VersionMap utility methods and improve implementation #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the VersionMap with new utility methods for size, emptiness, membership, mutation, and clearing; adds iteration helpers; refactors insertion and alternate tracking; optimizes lookup; and updates tests accordingly.
- Added standard collection methods (
len,is_empty,contains_version,clear,get_mut,get_first) and iteration APIs (versions,iter). - Refactored insertion logic into
insert_internal/update_alternates, implementedDefault, and optimizedgetto try exact match first. - Improved
removeto clean up alternate mappings and expanded test coverage for new behaviors.
Comments suppressed due to low confidence (2)
src/semver.rs:177
- [nitpick] After removing a version from the alternates set, consider removing its key when the set becomes empty to avoid leaving stale entries in
alternates.
set.remove(version);
src/semver.rs:163
- [nitpick] Add a unit test for
get_mutto verify that you can obtain and modify a stored value through a mutable reference.
pub fn get_mut(&mut self, version: &Version) -> Option<&mut T> {
1b678a7 to
e49a816
Compare
e49a816 to
eaf7ef3
Compare
eaf7ef3 to
a96c38a
Compare
2538a12 to
94a291f
Compare
2c69060 to
85fef49
Compare
9b3f645 to
2505633
Compare
85fef49 to
6c01479
Compare
6c01479 to
b2a41b4
Compare
3949476 to
da41053
Compare
da41053 to
d50e930
Compare
d50e930 to
41c9dad
Compare
bae0fd6 to
9807ba2
Compare
9807ba2 to
0d58c29
Compare
0d58c29 to
307fd1f
Compare
Code Coverage Report
Minimum allowed coverage is |

Enhanced VersionMap with Additional Utility Methods
This PR enhances the
VersionMapimplementation with several new utility methods and improves the internal structure:Added standard collection methods:
len(),is_empty(),contains_version()clear()to remove all versionsget_mut()for mutable access to valuesAdded iteration capabilities:
versions()to iterate over all versions in sorted orderiter()to iterate over version-value pairsget_first()to retrieve the lowest version and its valueImproved internal implementation:
DefaultforVersionMapget()method to check for exact match firstremove()to properly clean up alternates mappingAdded comprehensive tests for all new functionality
These changes make
VersionMapmore complete and consistent with standard Rust collection types.