Skip to content

Commit

Permalink
Merge pull request #1509 from nefelitav/union-syntax-patch
Browse files Browse the repository at this point in the history
union syntax fix for empty field list
  • Loading branch information
ehuss authored Jun 7, 2024
2 parents 6019b76 + b10666f commit 0b805c6
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 0b805c6

Please sign in to comment.