From b10666f10f6a731cfffbfc3c42841c59f8f76b58 Mon Sep 17 00:00:00 2001 From: nefelitav Date: Fri, 7 Jun 2024 17:05:10 +0200 Subject: [PATCH] union syntax fix --- src/items/unions.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/items/unions.md b/src/items/unions.md index 3c6c83d50..049564f2b 100644 --- a/src/items/unions.md +++ b/src/items/unions.md @@ -3,7 +3,7 @@ > **Syntax**\ > _Union_ :\ >    `union` [IDENTIFIER] [_GenericParams_]? [_WhereClause_]? -> `{`[_StructFields_] `}` +> `{`[_StructFields_]? `}` A union declaration uses the same syntax as a struct declaration, except with `union` in place of `struct`. @@ -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