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 Show for 1-12 element tuples and improve the std::tuple API #12313

Merged
merged 5 commits into from
Feb 16, 2014

Conversation

brendanzab
Copy link
Member

This renames the n* and n*_ref tuple getters to val* and ref* respectively, and adds mut* getters. It also removes the CloneableTuple and ImmutableTuple traits.

new_branch = new_outcome.clone().n0();
outcome = new_outcome.n1();
new_branch = new_outcome.get_0().clone();
outcome = new_outcome.get_1().clone();
Copy link
Member

Choose a reason for hiding this comment

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

You're adding extra clones here (not that it matters much given how many clones are in this file), it should really be

let (next_branch, next_outcome) = self.clone().rightmost_child.insert(...);
new_branch = next_branch;
outcome = next_outcome;

to avoid the clones. (And below too)

@brendanzab
Copy link
Member Author

Less clutter in the prelude! Yay!

fn $mutN<'a>(&'a mut self) -> &'a mut $T {
// Do this because the macro invocation would exceed
// the 100 character limit if it also required a
// $mut_pattern:pat
Copy link
Member

Choose a reason for hiding this comment

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

Seriously? You'll use unsafe code and violate some (possible) type invariants for a formatting issue?

Renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters.
These are adequately covered by the Tuple2 trait.
(n0, n0_ref) -> A { (a,_), (ref a,_) => a }
(n1, n1_ref) -> B { (_,b), (_,ref b) => b }
Tuple2 {
(val0, ref0, mut0) -> A { (a, b) => a }
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it's possible to move the (a, b, ...) bit of the macro expansion to near the Tuple<N> to only need to write it once for each tuple size.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, I tried this but I was getting complaints about the expansion depth.

@brendanzab
Copy link
Member Author

Bors didn't seem picking up the r+, so I'm trying a 'r=huonw'.

bors added a commit that referenced this pull request Feb 16, 2014
This renames the `n*` and `n*_ref` tuple getters to `val*` and `ref*` respectively, and adds `mut*` getters. It also removes the `CloneableTuple` and `ImmutableTuple` traits.
@bors bors closed this Feb 16, 2014
@bors bors merged commit f450b2b into rust-lang:master Feb 16, 2014
@brendanzab brendanzab deleted the tuple branch February 16, 2014 16:22
@flaper87
Copy link
Contributor

awesome, Thanks!

bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 25, 2022
Removed duplicate 'to' in `cachePriming.numThreads` option description

One 'to' too many!
flip1995 pushed a commit to flip1995/rust that referenced this pull request Feb 26, 2024
Upgrade anstream to 0.6.0

*Please write a short comment explaining your change (or "none" for internal only changes)*

changelog: none
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.

4 participants