Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
jdonszelmann authored and WaffleLapkin committed Jun 24, 2024
1 parent c73fce2 commit 3a4206f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/misc/9.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Misc 9 @adotinthevoid @jdonszelmann @victoronz
# Misc 9 @adotinthevoid @jdonszelmann @Victoronz @GoldsteinE

{{#include ../include/quiz-is-wip.md}}

Expand All @@ -13,13 +13,16 @@
{{#include ../../code/examples/stderr/misc_9.stderr}}
```

No matter what kind a struct is, it can always be initialized with braces (even if not declared with them). Therefor the first 3 statements are OK.
No matter what kind a struct is, it can always be initialized with braces (even if not declared with them). Therefore the first 3 statements are OK.

Destructuring assignment on a unit structs works as any other struct, and struct update syntax as well, even when there are no fields.
Only `Tuple` structs can be initialized with parentheses, because it's actually calling a constructor function.

`A;` on it's own is fine, because `A` is declared as a unit struct, so `A` is a constant of type `A`.
`Unit;` on it's own is fine, because `Unit` is declared as a unit struct, so `Unit` is a constant of type `Unit`.

`B;` on it's own is fine, because `B` as a value is the constructor for `B`, with type `fn() -> B`.
`Tuple;` on it's own is fine, because `Tuple` as a value is the constructor for `Tuple`, with type `fn() -> Tuple`.

`C;` is a compiler error, because `C` only exists as a type, and never a value.
`Struct;` is a compiler error, because `Struct` only exists as a type, and never a value.

Destructuring assignment on a unit structs works as any other struct,
and struct update syntax as well, even when there are no fields.
</details>

0 comments on commit 3a4206f

Please sign in to comment.