From 3885a81e5fa9913075537c9df857fa1753c5d7c1 Mon Sep 17 00:00:00 2001 From: Xavier Shay Date: Sat, 26 Sep 2015 11:59:00 -0700 Subject: [PATCH] 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. --- src/doc/trpl/structs.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/doc/trpl/structs.md b/src/doc/trpl/structs.md index 85b11d0b6b5ee..b51ad8e087d22 100644 --- a/src/doc/trpl/structs.md +++ b/src/doc/trpl/structs.md @@ -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