From 67a73e234da75070e93bef97e085820079b4aec7 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 21 Oct 2021 11:45:12 +0100 Subject: [PATCH 1/2] docs --- src/items/generics.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/items/generics.md b/src/items/generics.md index 0a9703335..152abb5e2 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/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 Uwu(U); ``` Generic parameters are in scope within the item definition where they are From cd3704e9aa4e28f0bc311ab7c23e5dfaf1f3c24d Mon Sep 17 00:00:00 2001 From: Ellen Date: Fri, 14 Jan 2022 02:54:26 +0000 Subject: [PATCH 2/2] reviews --- src/items/generics.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/items/generics.md b/src/items/generics.md index 152abb5e2..5ffcd1580 100644 --- a/src/items/generics.md +++ b/src/items/generics.md @@ -22,7 +22,7 @@ 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 and then type/const parameters intermixed. +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,7 +31,7 @@ fn foo<'a, T>() {} trait A {} struct Ref<'a, T> where T: 'a { r: &'a T } struct InnerArray([T; N]); -struct Uwu(U); +struct EitherOrderWorks(U); ``` Generic parameters are in scope within the item definition where they are