Skip to content
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

Derive Copy for std::ops::Range and RangeFrom #27186

Closed
wants to merge 1 commit into from

Conversation

Projects
None yet
6 participants
@SimonSapin
Copy link
Contributor

SimonSapin commented Jul 21, 2015

RangeTo and RangeFull already have it.

Derive Copy for std::ops::Range and RangeFrom
`RangeTo` and `RangeFull` already have it.
@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Jul 21, 2015

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @pcwalton (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. The way Github handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Jul 21, 2015

These don't have it because they're iterators.
The choice of removing Copy impls instead of adjusted for loop desugaring or linting was made to prevent this problematic case:

let mut iter = 0..n;
for i in iter { if i > 2 { break; } }
iter.collect()

Here iter is actually not mutated, but copied. for i in &mut iter is required to mutate the iterator.
We could switch to linting against using an iterator variable after it was copied by a for loop, but there was no decision towards that.

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Jul 21, 2015

Ok, so there was a reason.

“The choice […] was made” seems to contradict “no decision has been made yet.” If the decision against implementing Copy is made/confirmed, feel free to close this.

@alexcrichton

This comment has been minimized.

Copy link
Member

alexcrichton commented Jul 21, 2015

Yeah we've decided in the past to not take this, so I'm going to close this for now.

@SimonSapin SimonSapin deleted the SimonSapin:patch-6 branch Jul 21, 2015

@eddyb

This comment has been minimized.

Copy link
Member

eddyb commented Jul 21, 2015

@SimonSapin original phrasing was a bit off. What I meant to say was that no decision has been made for switching to linting (which my personal preference).

durka added a commit to durka/rust that referenced this pull request Jun 9, 2016

make RangeInclusive Hash and !Copy
[breaking-change] due to the removal of Copy which shouldn't have been there in the first place, as per policy set forth in rust-lang#27186.

@ExpHP ExpHP referenced this pull request Sep 1, 2017

Merged

Copy/Clone Closures #2132

@sanmai-NL

This comment has been minimized.

Copy link

sanmai-NL commented Jan 6, 2018

I favor a lint, since this code pattern is now not possible:

let three_times = 0_u32..3_u32;
for _ in three_times {
    ...
}
for _ in three_times {
    ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.