diff --git a/src/items/generics.md b/src/items/generics.md index 0a9703335..5ffcd1580 100644 --- a/src/items/generics.md +++ b/src/items/generics.md @@ -15,14 +15,14 @@ >    [IDENTIFIER]( `:` [_TypeParamBounds_]? )? ( `=` [_Type_] )? > > _ConstParam_:\ ->    `const` [IDENTIFIER] `:` [_Type_] +>    `const` [IDENTIFIER] `:` [_Type_] ( `=` _[Block][block]_ | [IDENTIFIER] | -?[LITERAL] )? [Functions], [type aliases], [structs], [enumerations], [unions], [traits], and [implementations] may be *parameterized* by types, constants, and lifetimes. These parameters are listed in angle brackets (`<...>`), usually immediately after the name of the item and before its definition. For implementations, which don't have a name, they come directly after `impl`. -The order of generic parameters is restricted to lifetime parameters, then type parameters, and then const parameters. +The order of generic parameters is restricted to lifetime parameters and then type and const parameters intermixed. Some examples of items with type, const, and lifetime parameters: @@ -31,6 +31,7 @@ fn foo<'a, T>() {} trait A {} struct Ref<'a, T> where T: 'a { r: &'a T } struct InnerArray([T; N]); +struct EitherOrderWorks(U); ``` Generic parameters are in scope within the item definition where they are