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

SimonSapin
Copy link
Contributor

RangeTo and RangeFull already have it.

`RangeTo` and `RangeFull` already have it.
@rust-highfive
Copy link
Collaborator

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
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
Copy link
Contributor Author

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
Copy link
Member

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

@SimonSapin SimonSapin deleted the patch-6 branch July 21, 2015 16:56
@eddyb
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
[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.
@sanmai-NL
Copy link

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants