-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Collections reform #235
RFC: Collections reform #235
Conversation
cc #17 |
|
||
impl<T: Eq> Predicate<T> for &T { | ||
fn check(&self, t: &T) -> bool { | ||
self == t |
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.
Pretty sure these need to be dereffed, unless the semantics of operators have changed from underneath me.
I skimmed/skipped the first 1000 lines assuming it hasn't changed much since last I saw it. Overall I'm a big 👍 to this proposal's contents. Some misc notes that I don't think you ever discussed/addressed:
|
@gankro I addressed the various typos you pointed out.
I don't think methods like That said, we could consider using
That's certainly doable. It's a tradeoff, since it makes the API somewhat more complex for a pretty rare use case. My plan for key recovery was to go through your collection view's RFC, which offers a bit more of a swiss army knife for working with maps. We'll have to think about sets, though. |
6357402
to
e0acdf4
Compare
It seems to me that it would be more flexible to define
(I'm not 100% clear about the rules for blanket Now if you define a custom string type, you can still get the benefits of
It also would let you have
Then
And you can still define
Did you consider implementing |
I want to like the idea of |
Hmm, this just occurred to me. The proposal states we would "deprecate" the traits. Is this intended literally (as in #[deprecated]), or will they just be removed overnight? Due to naming conflicts I'm pretty sure that the traits can't coexist in a deprecated form with the proposed concrete impls. Or will we have a brief period where the traits are deprecated as a warning, with no (merged) replacement? |
|
@sfackler I assumed that wording was simply referring to the standard deprecation -> removal path. I was (am?) uncertain about the nature of the transition. |
I might just be being dense, but is there a reason for the name |
Copy on write I'd assume. |
One thing I keep remembering and forgetting, and don't really know where to put it, so I'm just going to put here since it's relevant to this work: Instead of all this
This iterator should be DoubleEnded and therefore reversible. This of course doesn't address the inclusive/exclusive scenario, for which we can either do the same thing as
which is the solution I prefer. |
methods would go through a reference iterator (i.e. the `iter` method) rather | ||
than a moving iterator. | ||
|
||
It is possible to add such methods using the design proposed above, but there |
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.
It shouldn't produce a vector. Creating containers is very expensive and lazy iterators should be encouraged. An API producing temporary container will result in countless accidentally temporaries, as demonstrated by the code conventions in the compiler.
Following [the collections reform RFC](rust-lang/rfcs#235), this commit adds a new `borrow` module to libcore. The module contains traits for borrowing data (`BorrowFrom` and `BorrowFromMut`), generalized cloning (`ToOwned`), and a clone-on-write smartpointer (`Cow`).
Now that rust-lang#19448 has landed in a snapshot, we can add proper by-value operator overloads for `HashSet`. The behavior of these operator overloads is consistent with rust-lang/rfcs#235.
According to rust-lang/rfcs#235, `VecDeque` should have this method (`VecDeque` was called `RingBuf` at the time) but it was never implemented. I marked this stable since "1.0.0" because it's stable in `Vec`.
This is a combined conventions and library stabilization RFC. The goal is to establish a set of naming and signature conventions for
std::collections
.The major components of the RFC include:
collections
.MaybeOwned
.Iterable
.A big thank-you to @gankro, who helped collect API information and worked through an initial pass of some of the proposals here.
Rendered