Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upRFC: `.drain(range)` and `.drain()` #1257
Conversation
This was referenced Aug 14, 2015
This comment has been minimized.
This comment has been minimized.
|
Previous Vec::drain RFC: /pull/574 |
nrc
added
the
T-libs
label
Aug 17, 2015
alexcrichton
assigned
alexcrichton and
aturon
and unassigned
alexcrichton
Aug 19, 2015
This comment has been minimized.
This comment has been minimized.
|
@bluss Sorry for the lack of commentary! I was wondering if you can elaborate on the motivation for
but it's not entirely clear to me what you mean. Compared to the OTOH, |
This comment has been minimized.
This comment has been minimized.
|
It doesn't have to be a trait, it could be a function (parameterized over a different trait), to implement the same kind of bounds checking. That's mostly just to not have to repeat it in Vec::drain, String::drain, VecDeque::drain etc.
This refers mostly to other trait ideas that would convert all ranges to either a half open or closed range. These fail on tricky extreme values, since the maximum inclusive range does not fit inside an half open range without overflow, and So yes, I think an accessor for
|
This comment has been minimized.
This comment has been minimized.
I disagree with that: I'm concerned mostly about the public-facing API here. I'd much rather stabilize a general-purpose trait like |
This comment has been minimized.
This comment has been minimized.
|
Do you mean you disagree with replacing it? You can't disagree that it was added to support .drain(). That's how it was added. That's ok, I didn't really consider writing the general purpose range trait for this RFC, inclusive ranges were not even ready. Should it be part of this RFC? |
This comment has been minimized.
This comment has been minimized.
I disagree that its design is specific to drain. It doesn't really matter if drain happens to be the first API that wanted it :) |
This comment has been minimized.
This comment has been minimized.
|
I propose the range trait gets its own RFC and is removed from this one. |
This comment has been minimized.
This comment has been minimized.
|
cc @Stebalien We're writing a general range trait |
This comment has been minimized.
This comment has been minimized.
|
I agree with @aturon that it'd be nice to have the trait here be a more general than just for these collections its targeting. Avoiding I'd also personally prefer the trait to be considered as part of this RFC as it's difficult to stabilize the methods on collections without stabilizing the traits that they're parameterizing over. It's not unheard of, but it'd make me more comfortable to stabilize everything at once. |
alexcrichton
referenced this pull request
Sep 19, 2015
Closed
RangeArgument not exported to std::collections #28517
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton BTreeMap goes its own road (see the BTreeMap range RFC), and as noted here in this RFC, its drain should foremost be part of or consistent with its range iterator API. It doesn't look like they will use something similar to the index ranges that Vec::drain uses. |
This comment has been minimized.
This comment has been minimized.
|
BTreeMap's own road for drain is over at /pull/1254 |
This comment has been minimized.
This comment has been minimized.
|
I think we are getting derailed.
My aim here is to get put down on paper a mandate to implement My main questions that we need to get out of the way:
In my opinion, these are the questions that are blocking stabilization of any of the The range trait questions can be settled later. |
This comment has been minimized.
This comment has been minimized.
|
|
alexcrichton
added
the
final-comment-period
label
Oct 8, 2015
This comment has been minimized.
This comment has been minimized.
|
I'm personally OK with all stabilization and such here given that the trait to accept multiple ranges remains unstable (which I believe this is suggesting) |
This comment has been minimized.
This comment has been minimized.
Inherent methods are fine -- this isn't the time to add collection traits (still want HKT for that) and I don't think we want something one-off here. A trait can always be added later if the abstraction is called for.
Yes, I think it's OK. |
This comment has been minimized.
This comment has been minimized.
|
Thanks again for the RFC @bluss! The libs team discussed this RFC today and the decision was to merge, so I will do so. I'll also be reusing the stabilization issue as a tracking issue: rust-lang/rust#27711 |
alexcrichton
merged commit daf752d
into
rust-lang:master
Oct 15, 2015
This comment has been minimized.
This comment has been minimized.
|
Great. Thanks everyone for the input. |
bluss commentedAug 14, 2015
RFC:
.drain(range)and.drain()Implement
.drain(range)and.drain()respectively as appropriate on collections.Rendered