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 empty structs with braces. #147

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions active/0000-structs.md
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)
Copy link
Member

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).