Uh oh!
There was an error while loading. Please reload this page.
StrExt::splitn should not require a DoubleEndedSearcher - #23269
Conversation
rust-highfive
commented
Mar 11, 2015
(rust_highfive has picked a reviewer for you, use r? to override) |
shepmaster
commented
Mar 11, 2015
This has a couple of unanswered questions, so consider it a draft commit. I don't like having to add the duplication involved by creating |
There was a problem hiding this comment.
I think that the associated type on the Pattern trait already has this bound, so shouldn't this extra clause be unnecessary?
There was a problem hiding this comment.
Strictly, it is unnecessary, but having it here provide much better error messages. If you have this here, the error message lets you know that this call needs to be changed. Otherwise, the return type simply won't implement Iterator and you end up with "foo doesn't implement a method called {collect,map,etc}, try implementing Iterator".
alexcrichton
commented
Mar 11, 2015
cc @Kimundi, I vaguely remember there being a reason there may be a more strict requirement in some places? Not sure if this was intentional or accidental though. |
Kimundi
commented
Mar 13, 2015
I'm sorry, but I'm unhappy with most of this PR. :(
So, in summary I'd be fine with a fix to make I'd much rather see the compiler solve the error message problem in a general way, eg by deeply searching for the cause of why a trait might not be implemented: |
shepmaster
commented
Mar 14, 2015
No need to be sorry - that's the point of reviews!
This was a question in my original comment. I actually agree with this decision, but didn't want to change the semantics until someone knowledgable agreed.
Easily done. I'll amend this commit; should I open a topic on internals for the rest of it? Maybe as proto RFC? Not so sure on the current best process. |
Kimundi
commented
Mar 14, 2015
Hm, I think the motivation is applicable broadly enough that a internals discuss thread would be the best starting point. |
sfackler
commented
Mar 14, 2015
I doesn't sense to me to leave the correct bound off of the |
shepmaster
commented
Mar 14, 2015
For pedantry's sake, after this PR that will be true. |
a7c7f11 to
da68868Compareshepmaster
commented
Mar 15, 2015
@Kimundi I've got a new version up now, if you'd be so kind as to give it another look-see. The big thing that's new is that I've introduced I should add dedicated tests to both commits, however. |
Kimundi
commented
Mar 15, 2015
@sfackler:
That said, while writing this I changed mind: I just realized that we can preserve consistency by treating DoubleEndedIterator impls and reverse iterators differently, but uniformly so.
... and this, apparently is also how @shepmaster interpreted the situation, so yeah, patch looks good! Tests should definitely be added, but I wouldn't fuss too much about code layout and the code duplication introduced here: I've started working on a patch that adds the missing methods from the string pattern RFC, which also includes the changes here, and in which I try to reduce the general complexity of forward/backward iterator wrappers with a more specialized macro that generates them. Not sure when that will be done though, so I'd definitely try to get this PR merged first. |
da68868 to
a39209eCompareshepmaster
commented
Mar 15, 2015
@Kimundi Updated with tests and small doc changes. I think it's good-to-go now. Thanks! |
bors
commented
Mar 17, 2015
☔ The latest upstream changes (presumably #23104) made this pull request unmergeable. Please resolve the merge conflicts. |
a39209e to
c6ca220Compareshepmaster
commented
Mar 20, 2015
@Kimundi@alexcrichton updated to address merge conflicts. |
Kimundi
commented
Mar 21, 2015
Looks good to me |
There was a problem hiding this comment.
Sorry if I missed the context here, but the original motivation for this removal was that it duplicates the functionality of split(foo).rev() (whereas rsplitn has different semantics than splitn(foo).rev()). Was this added back just to get nicer error messages on the .rev() case? If so that may be covered by #23587 instead.
There was a problem hiding this comment.
was that it duplicates the functionality of split(foo).rev()
@alexcrichton With the conceptual difference of Searcher and ReverseSearcher, this is no longer true. For example, these are not the same:
"baaab".split("aa").rev();"baaab".rsplit("aa");There was a problem hiding this comment.
Oh right! I always forget about that...
Closes#23262