Skip to content

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

Merged
bors merged 1 commit into
rust-lang:masterfrom
sfackler:mut-pat
Dec 11, 2013
Merged

Allow ref and mut modifiers for short form field patterns#10833
bors merged 1 commit into
rust-lang:masterfrom
sfackler:mut-pat

Conversation

@sfackler

@sfackler sfackler commented Dec 6, 2013

Copy link
Copy Markdown
Member

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

huonw commented Dec 6, 2013

Copy link
Copy Markdown
Contributor

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

@alexcrichton

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

huonw commented Dec 6, 2013

Copy link
Copy Markdown
Contributor

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

sfackler commented Dec 6, 2013

Copy link
Copy Markdown
Member Author

Will do

@brson

brson commented Dec 6, 2013

Copy link
Copy Markdown
Contributor

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

@pcwalton

pcwalton commented Dec 7, 2013

Copy link
Copy Markdown
Contributor

+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