diff --git a/src/items/structs.md b/src/items/structs.md index 1a863411a8..26f3421d5a 100644 --- a/src/items/structs.md +++ b/src/items/structs.md @@ -1,5 +1,41 @@ # Structs +> **Syntax** +> _Struct_ : +>       _StructStruct_ +>    | _TupleStruct_ +> +> _StructStruct_ : +>    `struct` +> [IDENTIFIER]  +> [_Generics_]? +> [_WhereClause_]? +> ( `{` _StructFields_? `}` | `;` ) +> +> _TupleStruct_ : +>    `struct` +> [IDENTIFIER]  +> [_Generics_]? +> `(` _TupleFields_? `)` +> [_WhereClause_]? +> `;` +> +> _StructFields_ : +>    _StructField_ (`,` _StructField_)\* `,`? +> +> _StructField_ : +>    [_OuterAttribute_]\* +>    [_Visibility_] +>    [IDENTIFIER] `:` [_Type_] +> +> _TupleFields_ : +>    _TupleField_ (`,` _TupleField_)\* `,`? +> +> _TupleField_ : +>    [_OuterAttribute_]\* +>    [_Visibility_] +>    [_Type_] + A _struct_ is a nominal [struct type] defined with the keyword `struct`. An example of a `struct` item and its use: @@ -43,3 +79,10 @@ The precise memory layout of a struct is not specified. One can specify a particular layout using the [`repr` attribute]. [`repr` attribute]: attributes.html#ffi-attributes + +[_OuterAttribute_]: attributes.html +[IDENTIFIER]: identifiers.html +[_Generics_]: items.html#type-parameters +[_WhereClause_]: items.html#type-parameters +[_Visibility_]: visibility-and-privacy.html +[_Type_]: types.html