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

Implement Clone for tuples #5692

Closed
wants to merge 1 commit into from
Closed

Conversation

Aatch
Copy link
Contributor

@Aatch Aatch commented Apr 3, 2013

This implements the clone interface for tuples and adds a test to match. The implementation is only on tuples that have elements that are themselves clone-able. This should allow for `#[deriving(Clone)] on nominal types that contain tuples somewhere.

@@ -46,6 +47,15 @@ impl<T:Copy,U:Copy> CopyableTuple<T, U> for (T, U) {

}

impl<T:Clone,U:Clone> Clone for (T, U) {
fn clone(&self) -> (T, U) {
let (a, b) = match *self {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use let (ref a, ref b) = *self here? or does that hit something like an ICE?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. #3874 and #3235 (mainly the latter).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, presumably, #5689, which for all I know might be a subset of one of those.

bors added a commit that referenced this pull request Apr 3, 2013
This implements the clone interface for tuples and adds a test to match. The implementation is only on tuples that have elements that are themselves clone-able. This should allow for `#[deriving(Clone)] on nominal types that contain tuples somewhere.
@bors bors closed this Apr 3, 2013
tesuji pushed a commit to tesuji/rustc that referenced this pull request Jun 9, 2020
reversed_empty_ranges: avoid linting N..N except in for loop arguments

changelog: [`reversed_empty_ranges`]: avoid linting N..N except in for loop arguments

r? @yaahc
Fixes rust-lang#5689
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.

5 participants