-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Change the &mut T pattern to &mut. #179
Conversation
Increasing consistency is always great. +1 BTW, isn't the fact that |
Yes, that's exactly what causes that. |
+1 for the same reasons mentioned in the proposal. |
another potential "drawback" (though certainly some might see it as a feature of the RFC, not a drawback): a macro that expands into a pattern |
(Updated from feedback.) |
👍 |
+1 from me, though for consistency it would be nice if supporting |
+1 to Kimundi's suggestion (which is mentioned in passing in the RFC Drawbacks section where it says that "disambiguating like |
Agreed, I'd also like to see |
I found exactly one instance of |
(Note to self: it was decided that I would collect a bit more data about how often |
I remain divided on this. On the one hand, I recognize that this has the potential to be a future wart, and it has only a minor impact on existing code. On the other hand, it just seems repetitive to have to write Finally, I was thinking about the plans for the For example, one could write:
Now, we could (maybe?) force you to write I see a couple of options:
|
(I should note though that the |
For a while early on, I kept writing (Of the alternatives, a single unified deref pattern also sounds appealing, if there's some satisfying syntax we could use for it, which I'm not sure of.) |
On Sat, Aug 09, 2014 at 08:48:57AM -0700, Gábor Lehel wrote:
Having thought about it for a bit, I think you expressed my current |
+1, find the bug in this code: let mut foo = 1u;
let bar: |&mut uint| = |&mut n| n += 100;
bar(&mut foo);
foo One data point is not much, but someone came with this issue to the IRC. |
6357402
to
e0acdf4
Compare
👍 It’s great to see a proposal that makes patterns mirror their expression counterparts more closely. One of my favourite things about pattern matching (usually regardless of language) is that in an assignment, you can usually modify each side in the same way and not change the behaviour (unless the borrow checker or refutability gets in your way): let x = 1i;
assert_eq!(x, 1i);
let &x = &1i;
assert_eq!(x, 1i);
let TupleStruct(&x) = TupleStruct(&1i);
assert_eq!(x, 1i);
// With this RFC:
let &mut TupleStruct(&x) = &mut TupleStruct(&1i);
assert_eq!(x, 1i);
// You can even work in reverse to ‘solve’ an assignment like a mathematical equation:
let &mut TupleStruct(&x) = &mut TupleStruct(&1i);
let TupleStruct(&x) = TupleStruct(&1i);
let &x = &1i;
let x = 1i; It’s sad to see that discussion on this RFC has stalled, though—what exactly would it take to get this RFC to move further through the RFC process? This is a backwards-incompatible change, after all. |
Oh, whoops, forgot about this. I'll try to make some measurement and discuss with people tomorrow. |
Here's the things that were detected in stage1 of a plain
And here's what was detected in the crates in servo that use their
I.e. not that many. (Those are using the type checker so should detect everything in the crate, modulo conditional compilation.) |
(Implemented here, staging means that most of the library changes cannot be done yet, but there is two instances of the |
Seems to be consensus. Merged. Tracking. |
No description provided.