From 3c5001f0dd14c3d0afa539eaed9c9109de2aae59 Mon Sep 17 00:00:00 2001 From: Josef Brandl Date: Tue, 28 Feb 2017 11:28:54 +0100 Subject: [PATCH 1/2] Unit-like structs doc: Improve code sample --- src/doc/book/src/structs.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/doc/book/src/structs.md b/src/doc/book/src/structs.md index 6b2a145c85e51..b5fe99d04868a 100644 --- a/src/doc/book/src/structs.md +++ b/src/doc/book/src/structs.md @@ -259,9 +259,10 @@ You can define a `struct` with no members at all: struct Electron {} // Use empty braces... struct Proton; // ...or just a semicolon. -// Whether you declared the struct with braces or not, do the same when creating one. +// Use the same notation when creating an instance. let x = Electron {}; let y = Proton; +let z = Electron; // Error ``` Such a `struct` is called ‘unit-like’ because it resembles the empty From 8f1a0afee1fd34e667de11b706569d5d05573140 Mon Sep 17 00:00:00 2001 From: Josef Brandl Date: Wed, 1 Mar 2017 10:03:07 +0100 Subject: [PATCH 2/2] Unit-like structs doc: Add compile fail tag --- src/doc/book/src/structs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/doc/book/src/structs.md b/src/doc/book/src/structs.md index b5fe99d04868a..9f61e5b66289b 100644 --- a/src/doc/book/src/structs.md +++ b/src/doc/book/src/structs.md @@ -255,7 +255,7 @@ rather than positions. You can define a `struct` with no members at all: -```rust +```rust,compile_fail,E0423 struct Electron {} // Use empty braces... struct Proton; // ...or just a semicolon.