Closed
Description
RFC 1682 added "field init shorthand" (tracking issue is #37340), which allows you to use a shorthand in struct literals:
struct Foo { x } => struct Foo { x: x }
This is implemented on nightly and we would like to stabilize it, but documentation is required. Here is a list of places where the documentation would need to be updated, kindly prepared by @havvy:
- The grammar needs updating (PR: Update struct_expr grammar for field init shorthand. #38956)
- as would adding a section to the book and the new book.
- The reference would need a paragraph explaining the sugar.
- Additionally, we may want to add examples to Rust By Example showing the syntax.
- A changelog entry is needed. @Havvy proposes this short entry: "Added field init shorthand syntax when the field and variable names match."
I'm marking this as E-mentor, since updating these docs seems like a pretty good starter bug.
Metadata
Assignees
Labels
Area: Documentation for any part of the project, including the compiler, standard library, and toolsCategory: An issue proposing an enhancement or a PR with one.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Medium priority