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

RFC: Add syntaxic sugar for struct expressions fields from variables of the same name #11990

Closed
SimonSapin opened this issue Feb 2, 2014 · 6 comments
Labels
A-parser Area: The parsing of Rust source code to an AST

Comments

@SimonSapin
Copy link
Contributor

The general syntax for a struct pattern is:

StructName { field_name: new_variable_name }

But when the desired variable name is the same as the field name, it does not need to be repeated:

let MyStruct { name } = struct_value;
do_something_with(name);

This proposal is to add similar syntax sugar for struct expressions:

let name = …;
let struct_value = MyStruct { name };

… would be the same as:

let name = …;
let struct_value = MyStruct { name: name };

CC: @eddyb

@rapha
Copy link
Contributor

rapha commented Feb 4, 2014

OCaml has this. It's nice. I'd support it.

@alexcrichton
Copy link
Member

Closed with [my comment] on #11994.

@alexcrichton
Copy link
Member

@alexcrichton alexcrichton reopened this Feb 11, 2014
@nham
Copy link
Contributor

nham commented Aug 18, 2014

Triage bump.

@eddyb
Copy link
Member

eddyb commented Aug 18, 2014

Shouldn't this have to go through the RFC process now?

@rust-highfive
Copy link
Collaborator

This issue has been moved to the RFCs repo: rust-lang/rfcs#306

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area: The parsing of Rust source code to an AST
Projects
None yet
Development

No branches or pull requests

6 participants