Skip to content

Add min specialisation for RangeFrom - #47362

Closed
varkor wants to merge 1 commit into
rust-lang:masterfrom
varkor:range-from-min
Closed

Add min specialisation for RangeFrom#47362
varkor wants to merge 1 commit into
rust-lang:masterfrom
varkor:range-from-min

Conversation

@varkor

@varkorvarkor commented Jan 11, 2018

Copy link
Copy Markdown
Contributor

Calling min on RangeFrom currently causes an infinite loop. Although other methods such as max also result in an infinite loop, it is strictly incorrect in the case of min. Adding a specialisation fixes this.

Separated from #47180 because this technically changes behaviour; it’s not just an optimisation, so it’s a little different.

r? @alexcrichton

Calling `min` on `RangeFrom` currently causes an infinite loop.
Although other methods such as `max` also result in an infinite loop,
it is strictly incorrect in the case of `min`. Adding a specialisation
fixes this.
Separated from rust-lang#47180 because
this technically changes behaviour; it’s not just an optimisation, so
it’s a little different.
@kennytmkennytm added T-libs-api [DEPRECATED; DO NOT USE] S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 11, 2018
@alexcrichton

Copy link
Copy Markdown
Member

@bors: r+

@bors

bors commented Jan 11, 2018

Copy link
Copy Markdown
Collaborator

📌 Commit 554fbc2 has been approved by alexcrichton

@ollie27

Copy link
Copy Markdown
Contributor

If this is valid implementation of min then should Repeat also implement min, max etc. like this?

@varkor

Copy link
Copy Markdown
ContributorAuthor

@ollie27 — I was waiting for this change to be approved before correcting the behavior of other infinite iterators, but you're right: I have a PR for Repeat and Cyclehere now.

@scottmcm

Copy link
Copy Markdown
Member

This is an insta-stable behavior change, not just an optimization, so I really think it needs an FCP.

It results in min() and min_by_key(|x| x) doing different things, which feels really weird to me.

@sfackler

Copy link
Copy Markdown
Member

I am also not totally on board with this change.

@alexcrichton

Copy link
Copy Markdown
Member

@bors: r-

er sorry I didn't realize this was a behavior change!

@varkor mind detaling why you think this behavior change is ok? e.g. enabling this on this iterator?

@varkor

Copy link
Copy Markdown
ContributorAuthor

@alexcrichton: Sorry, I should have made it clearer! It makes sense to have this discussion in one place, so maybe let's move it to #47370 where it's already going on.

@alexcrichton

Copy link
Copy Markdown
Member

Sure yeah sounds good to me!

@varkor

Copy link
Copy Markdown
ContributorAuthor

Better to close this one for now as per the discussions in #47370. Sorry for the confusion!

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-reviewStatus: Awaiting review from the assignee but also interested parties.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

@varkor@alexcrichton@bors@ollie27@scottmcm@sfackler@kennytm