Skip to content
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

Implement values_mut on {BTree, Hash}Map #32633

Merged
merged 2 commits into from
Apr 3, 2016

Conversation

frewsxcv
Copy link
Member

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

/// Mutable HashMap values iterator.
#[unstable(feature = "map_values_mut", reason = "recently added", issue = "32551")]
pub struct ValuesMut<'a, K: 'a, V: 'a> {
inner: Map<IterMut<'a, K, V>, fn((&'a K, &'a mut V)) -> &'a mut V>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there any reason that you chose to use Map here and not in BTreeMap's ValuesMut? I don't think that there are variance issues (since &mut forces V to be invariant anyway), but the inconsistency seems a little weird.

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, now that I think about it some more, using Map makes K incorrectly invariant. This probably doesn't matter in practice, but I'd still be more comfortable implementing that mapping by hand and getting the correct covariance.

Copy link
Member Author

Choose a reason for hiding this comment

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

I chose Map here for HashMap::ValuesMut because HashMap::Values uses a Map.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, that makes sense. I think the existing iterators are actually incorrect with respect to variance then - see #30642.

@frewsxcv
Copy link
Member Author

Maybe I'll wait for #32635 merge before moving forward on this.

@frewsxcv
Copy link
Member Author

frewsxcv commented Apr 1, 2016

#32635 merged and this PR is now rebased on top of those changes.

@alexcrichton
Copy link
Member

Looks the travis error is legit (an error in one of the tests)

@frewsxcv
Copy link
Member Author

frewsxcv commented Apr 1, 2016

@alexcrichton Which error are you looking at? If possible, could you paste in here?

@frewsxcv
Copy link
Member Author

frewsxcv commented Apr 1, 2016

Nevermind. Found it. Fixing.

@alexcrichton
Copy link
Member

Looks like the features in the doctests may still be off?

(I'd recommend running make check)

@frewsxcv
Copy link
Member Author

frewsxcv commented Apr 2, 2016

Seems to pass the tests now.

@alexcrichton
Copy link
Member

@bors: r+ 2084f2e

@bors
Copy link
Contributor

bors commented Apr 3, 2016

⌛ Testing commit 2084f2e with merge 080edd9...

bors added a commit that referenced this pull request Apr 3, 2016
Implement `values_mut` on `{BTree, Hash}Map`

#32551
@bors bors merged commit 2084f2e into rust-lang:master Apr 3, 2016
@frewsxcv frewsxcv deleted the map-values-mut branch April 3, 2016 16:01
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.

6 participants