-
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
Allow empty structs with braces. #147
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
- Start Date: 2014-06-30 | ||
- RFC PR #: (leave this empty) | ||
- Rust Issue #: (leave this empty) | ||
|
||
# Summary | ||
|
||
Allow empty structs with braces. | ||
|
||
# Motivation | ||
|
||
`struct X;` is an exception that was necessary because of ambiguous code such as `if x == X { } { ... }`. | ||
With [this PR](https://github.com/rust-lang/rust/pull/14885) the ambiguity no longer exists. | ||
|
||
## Definitive list of reasons to do this. | ||
|
||
- 64% (or so) of those who voted want this (+1 vs. -1). | ||
- Macros without special cases for zero elements. | ||
- Ease the transition between empty and non-empty structs: `struct X { _sigh: () }`. | ||
- Consistency with C code. People find this weird when learning Rust. | ||
- Consistency with Rust code: `trait X { }`, `enum X { }`, `fn x() { }`, `mod X { }`. | ||
- Clarity: `let x = X { };` is a struct. | ||
|
||
# Detailed design | ||
|
||
Replace `;` by `{ }` everywhere. | ||
|
||
# Drawbacks | ||
|
||
None. | ||
|
||
# Alternatives | ||
|
||
N/A | ||
|
||
# Unresolved questions | ||
|
||
TIOOWTDI (with a majority in favor) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am guessing that this is meant to denote "There Is Only One Way To Do It." (But in that case, why is it in the "Unresolved Questions" section rather than "Drawbacks" section? And really, the point needs to be explicitly elaborated.)
Acronyms like this are appropriate for SMS messages and twitter; not for a documents like this, especially since some of the core team members did not know what this meant (and I didn't figure out a guess for it until well after seeing their conversation).