Skip to content

Commit 3c5001f

Browse files
Unit-like structs doc: Improve code sample
1 parent e1cb9ba commit 3c5001f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Diff for: src/doc/book/src/structs.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,10 @@ You can define a `struct` with no members at all:
259259
struct Electron {} // Use empty braces...
260260
struct Proton; // ...or just a semicolon.
261261

262-
// Whether you declared the struct with braces or not, do the same when creating one.
262+
// Use the same notation when creating an instance.
263263
let x = Electron {};
264264
let y = Proton;
265+
let z = Electron; // Error
265266
```
266267

267268
Such a `struct` is called ‘unit-like’ because it resembles the empty

0 commit comments

Comments
 (0)