Skip to content

Commit 3885a81

Browse files
committed
Add an example of constructing a unit-like struct.
This was non-obvious to me: with no example, I assumed `Electron {}` and didn't know what else to try when it didn't work. The correct form is weird because it looks like you're assigning the struct name rather than an instance of the struct.
1 parent 9169e6c commit 3885a81

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

src/doc/trpl/structs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ You can define a `struct` with no members at all:
184184

185185
```rust
186186
struct Electron;
187+
188+
let x = Electron;
187189
```
188190

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

0 commit comments

Comments
 (0)