Skip to content

Commit b1bd60b

Browse files
Rollup merge of rust-lang#40144 - MajorBreakfast:patch-7, r=frewsxcv
Unit-like structs doc: Improve code sample r? @steveklabnik BTW it seems that ```Rust let p = Proton {}; ``` compiles without an error. That's why I didn't add it to the example. It's about consistency anyway.
2 parents 5d08775 + 8f1a0af commit b1bd60b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/doc/book/src/structs.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -255,13 +255,14 @@ rather than positions.
255255

256256
You can define a `struct` with no members at all:
257257

258-
```rust
258+
```rust,compile_fail,E0423
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)