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.
This commit is contained in:
parent
9169e6c53c
commit
3885a81e5f
@ -184,6 +184,8 @@ You can define a `struct` with no members at all:
|
||||
|
||||
```rust
|
||||
struct Electron;
|
||||
|
||||
let x = Electron;
|
||||
```
|
||||
|
||||
Such a `struct` is called ‘unit-like’ because it resembles the empty
|
||||
|
Loading…
x
Reference in New Issue
Block a user