Skip to content

Commit

Permalink
union syntax fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nefelitav committed Jun 7, 2024
1 parent 6019b76 commit b10666f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/items/unions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
> **<sup>Syntax</sup>**\
> _Union_ :\
> &nbsp;&nbsp; `union` [IDENTIFIER]&nbsp;[_GenericParams_]<sup>?</sup> [_WhereClause_]<sup>?</sup>
> `{`[_StructFields_] `}`
> `{`[_StructFields_]<sup>?</sup> `}`
A union declaration uses the same syntax as a struct declaration, except with
`union` in place of `struct`.
Expand All @@ -30,6 +30,8 @@ This restriction ensures, in particular, that union fields never need to be
dropped. Like for structs and enums, it is possible to `impl Drop` for a union
to manually define what happens when it gets dropped.

Unions without any fields are not accepted by the compiler, but can be accepted by macros.

## Initialization of a union

A value of a union type can be created using the same syntax that is used for
Expand Down

0 comments on commit b10666f

Please sign in to comment.