From 6a82da5f59c4a775c36feb95140f19765a155ac5 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Mon, 30 Jun 2014 22:15:27 +0200 Subject: [PATCH 1/2] allow empty structs --- active/0000-structs.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 active/0000-structs.md diff --git a/active/0000-structs.md b/active/0000-structs.md new file mode 100644 index 00000000000..aa34ec0c89d --- /dev/null +++ b/active/0000-structs.md @@ -0,0 +1,30 @@ +- 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. + +# Detailed design + +Allow `struct X { }`. +Remove or keep `struct X;`. +Some people might want to keep `let x = X;`. + +# Drawbacks + +None that I know of. + +# Alternatives + +N/A + +# Unresolved questions + +None that I know of. From da99b541f0dde23e6b5e1b28eb6e205485ccf036 Mon Sep 17 00:00:00 2001 From: Julian Orth Date: Tue, 5 Aug 2014 14:26:37 +0200 Subject: [PATCH 2/2] update --- active/0000-structs.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/active/0000-structs.md b/active/0000-structs.md index aa34ec0c89d..6a1d7944ca8 100644 --- a/active/0000-structs.md +++ b/active/0000-structs.md @@ -11,15 +11,22 @@ Allow empty structs with braces. `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 -Allow `struct X { }`. -Remove or keep `struct X;`. -Some people might want to keep `let x = X;`. +Replace `;` by `{ }` everywhere. # Drawbacks -None that I know of. +None. # Alternatives @@ -27,4 +34,4 @@ N/A # Unresolved questions -None that I know of. +TIOOWTDI (with a majority in favor)