Uh oh!
There was an error while loading. Please reload this page.
Add Iterator::rfind. - #39399
Conversation
rust-highfive
commented
Jan 29, 2017
(rust_highfive has picked a reviewer for you, use r? to override) |
I think this is good. It's in line with the fold_ok ideas in two ways
|
bluss
commented
Jan 30, 2017
Implementation-wise I'd write this directly using |
alexcrichton
commented
Jan 30, 2017
@bluss could you expand on the point about the location of the method? I vaguely recall that this was a thing in the past but can't recall specifics right now |
bluss
commented
Jan 30, 2017
It's just that isn't it more natural to have a method directly on the trait where the method's functionality is enabled, instead of Provided method on the supertrait ( Since it's a method with a provided implementation, giving a specific impl for it should be easy either way. Though I have not explored it in detail, adding specializations for it is complicated (even incompatible?) if this method sits on |
I agree with @bluss on the fact that Unfortunately, that'd be a super-breaking change because implementors of The reason why I added this to |
I'd prefer to add |
clarfonthey
commented
Jan 31, 2017
@bluss I feel like it'd be off-putting to find this one method in |
alexcrichton
commented
Jan 31, 2017
@bluss ah ok, thanks for the explanation! IIRC one motivation for putting everything on |
clarfonthey
commented
Jan 31, 2017
I personally feel like precedent is good but we should also open up a dedicated issue for eventually moving these to the right place. |
bluss
commented
Feb 1, 2017
I really think that once you recognize an error, you do your best to (1) fix it and (2) not repeat it. I'm not fond of the idea of sticking it in the Can't move the existing methods, but we can stop repeating the same error.
I don't think we serve users well this way, it's another inconsistent rule about std they will have to learn. (Any other trait that does the same thing?) The method's location should be decided by where its functionality is enabled, by the construction of the feature, not by how we want to present it. |
clarfonthey
commented
Feb 1, 2017
That's fair. For consistency, maybe we could try moving the other two methods and do a crater run to see the impact? |
alexcrichton
commented
Feb 2, 2017
Er well I guess my point is that I don't think we made an error. I find it quite useful to have a one-stop-shop for all iterator API documentation and would be sad to see it split across a number of traits. @rust-lang/libs do others have an opinion on this here? The specific question being debated is where a function like this should live. @blussbelieves APIs should live on the trait they're associated with, where I personally prefer to keep all the iterator docs in one place. |
bluss
commented
Feb 2, 2017
It's a well-intentioned kind of “nice” that leaves a spaghetti trail. (Should BufRead extension methods like |
aturon
commented
Feb 2, 2017
Note that Of course, that's not really the right location, and having So I think the real question here is: what should be done for a method that's available only when two distinct traits ( Having the method live on |
bluss
commented
Feb 2, 2017
|
aturon
commented
Feb 2, 2017
@bluss Understood -- was just trying to give more historical context. @alexcrichton Given the context above, do you still feel strongly that the method should live on |
clarfonthey
commented
Feb 3, 2017
IMHO the only benefit to having more functions in iterator is being able to use However, in the case of this function, it's worth noting that because it's unstable, it can be moved after this PR is merged. We could always put this sort of discussion in the tracking issue. |
alexcrichton
commented
Feb 3, 2017
Ok let's just put this method on DEI then |
clarfonthey
commented
Feb 3, 2017
It has been moved. |
alexcrichton
commented
Feb 3, 2017
@bors: r+ |
bors
commented
Feb 3, 2017
📌 Commit 3cf485c has been approved by |
bluss
commented
Feb 3, 2017
Thanks for working on this. There's a chance I'll propose |
bors
commented
Feb 4, 2017
Add Iterator::rfind. I found it weird that `Iterator` has `rpostition` but not `rfind`. This adds that method.
bors
commented
Feb 4, 2017
☀️ Test successful - status-appveyor, status-travis |
I found it weird that
Iteratorhasrpostitionbut notrfind. This adds that method.