-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Use wrapper structs for iterators in BTreeMap/Set and HashMap/Set #19770
Conversation
@@ -610,8 +610,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> { | |||
} | |||
|
|||
/// HashSet iterator | |||
pub type SetItems<'a, K> = | |||
iter::Map<'static, (&'a K, &'a ()), &'a K, Entries<'a, K, ()>>; | |||
pub type SetItems<'a, K> = Keys<'a, K, ()>; |
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.
Admittedly, it's sort of a band-aid to switch from one type alias to another here, but I figured it's better to go with the path of least change in this pull request to keep it focused. However, I am working on another separate pull request based on top of this one to clean up HashSet
a little (including but not limited to doing the type alias conversions), so a proper solution for this is coming.
r? @gankro |
self.inner.size_hint() | ||
} | ||
} | ||
|
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.
Might as well flatten these?
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.
I was conforming to local file style here. Would you like me to flatten the couple of impl's that look like this just above as well?
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.
Sure.
LGTM. But I just realized that this is technically a breaking change to do (since it's fair-game to treat a type-alias as the aliased type). Need to mark the PR as a |
Cool, never done that before so let me just clarify...the |
Has to go at the end of the PR or the commit. I usually do both. You should also note e.g. how to deal with the breakage (in this case, just need to note that it is no longer an alias, but a proper new type). |
6870bf1
to
b9dacbe
Compare
Cool, |
So, I just got finished doing the same type of conversion for BTreeSet and HashSet and debated whether to open a new pull request for them or tack them on here. I decided that since it's the same thing, and because the HashSet changes need to be based on top of this PR, that adding them on to this one would be best. |
BTreeMap
and HashMap
Should be fine. |
48e05bc
to
e38de8a
Compare
All right, and now I've gotten this rebased post-closure unboxing. |
(I'll let you in on a secret: I'm not really looking very hard this time) |
Hmm, just out of curiosity, what is the 'rollup' command for bors? I've never seen it before! |
Use wrapper structs for iterators in BTreeMap/Set and HashMap/Set Reviewed-by: Gankro
Dang it...looks like BTreeSet doesn't use core::iter anymore and I forgot to remove it. While that didn't fail my local build, it just caused the buildbot to fail the rollup. I'll get that fixed ASAP :( Edit: @gankro Removed the offending |
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This commit changes the keys and values iterators of `BTreeMap` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This commit changes the iterators of `BTreeSet` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This commit changes the keys and values iterators of `HashMap` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This commit changes the iterators of `HashSet` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
e38de8a
to
341cf40
Compare
Are you running full |
So, I must admit that for this particular case I used No matter, I will just make sure to run the full test suite from now on and I'll ping you once I ensure that |
It's not a compilation or test error, it's a lint. It's likely that check-LIBRARY doesn't bother with that stuff. It still would have shown up as a warning in the logs, though. ( and yeah, we've all messed up by not doing a full check :D ) |
Duly noted that |
Use wrapper structs for iterators in BTreeMap/Set and HashMap/Set Reviewed-by: Gankro
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This commit changes the iterators of `VecMap` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Use wrapper structs for iterators in BTreeMap/Set and HashMap/Set Reviewed-by: Gankro
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This PR changes the iterators of `BTreeMap`, `BTreeSet`, `HashMap`, and `HashSet` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Use wrapper structs for iterators in BTreeMap/Set and HashMap/Set Reviewed-by: Gankro
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code. This PR changes the iterators of `BTreeMap`, `BTreeSet`, `HashMap`, and `HashSet` to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a: [breaking-change].
Using a type alias for iterator implementations is fragile since this exposes the implementation to users of the iterator, and any changes could break existing code.
This PR changes the iterators of
BTreeMap
,BTreeSet
,HashMap
, andHashSet
to use proper new types, rather than type aliases. However, since it is fair-game to treat a type-alias as the aliased type, this is a:[breaking-change].