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

Allow ref and mut modifiers for short form field patterns #10833

Merged
merged 1 commit into from
Dec 11, 2013

Conversation

sfackler
Copy link
Member

@sfackler sfackler commented Dec 6, 2013

Previously, if you wanted to bind a field mutably or by ref, you had to
do something like Foo { x: ref mut x }. You can now just do
Foo { ref mut x }.

Closes #6137

@huonw
Copy link
Member

huonw commented Dec 6, 2013

Could the test include Foo { mut x } and Foo { ref x }?

@alexcrichton
Copy link
Member

This is amazing! I've always wanted this.

If you expand the test coverage I'd r+. In addition to what @huonw mentioned, it'd be nice to see some coverage of making sure that 'ref mut' requires the binding to mutable, 'ref' doesn't move, things like that.

@huonw
Copy link
Member

huonw commented Dec 6, 2013

Also, probably worth checking multiple fields Foo { ref x, ref y }, and combinations like Foo { x: whatever, ref y } and Foo { mut y, .. } work.

@sfackler
Copy link
Member Author

sfackler commented Dec 6, 2013

Will do

@brson
Copy link
Contributor

brson commented Dec 6, 2013

Since this is a change to the language we should probably discuss it in a meeting.

@pcwalton
Copy link
Contributor

pcwalton commented Dec 7, 2013

+1

Previously, if you wanted to bind a field mutably or by ref, you had to
do something like Foo { x: ref mut x }. You can now just do
Foo { ref mut x }.

Closes rust-lang#6137
bors added a commit that referenced this pull request Dec 11, 2013
Previously, if you wanted to bind a field mutably or by ref, you had to
do something like Foo { x: ref mut x }. You can now just do
Foo { ref mut x }.

Closes #6137
@bors bors closed this Dec 11, 2013
@bors bors merged commit 8240faf into rust-lang:master Dec 11, 2013
@sfackler sfackler deleted the mut-pat branch December 23, 2013 03:52
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.

There should be a shorthand for foo: ref foo in struct field patterns.
6 participants