Unit-like structs doc: Improve code sample
This commit is contained in:
parent
e1cb9ba221
commit
3c5001f0dd
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user