Skip to content

Commit 74e9629

Browse files
authored
show both forms of empty struct declaration
1 parent 56f24d7 commit 74e9629

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/doc/book/structs.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,12 @@ rather than positions.
234234
You can define a `struct` with no members at all:
235235

236236
```rust
237-
struct Electron {}
237+
struct Electron {} // use empty braces...
238+
struct Proton; // ...or just a semicolon
238239

240+
// whether you declared the struct with braces or not, do the same when creating one
239241
let x = Electron {};
242+
let y = Proton;
240243
```
241244

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

0 commit comments

Comments
 (0)