Skip to content

Commit 4dc4757

Browse files
authored
Merge pull request #1098 from BoxyUwU/cg_defaults_docs
document `#![feature(const_generics_defaults)]`
2 parents ee00666 + cd3704e commit 4dc4757

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/items/generics.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@
1515
> &nbsp;&nbsp; [IDENTIFIER]( `:` [_TypeParamBounds_]<sup>?</sup> )<sup>?</sup> ( `=` [_Type_] )<sup>?</sup>
1616
>
1717
> _ConstParam_:\
18-
> &nbsp;&nbsp; `const` [IDENTIFIER] `:` [_Type_]
18+
> &nbsp;&nbsp; `const` [IDENTIFIER] `:` [_Type_] ( `=` _[Block][block]_ | [IDENTIFIER] | -<sup>?</sup>[LITERAL] )<sup>?</sup>
1919
2020
[Functions], [type aliases], [structs], [enumerations], [unions], [traits], and
2121
[implementations] may be *parameterized* by types, constants, and lifetimes. These
2222
parameters are listed in angle <span class="parenthetical">brackets (`<...>`)</span>,
2323
usually immediately after the name of the item and before its definition. For
2424
implementations, which don't have a name, they come directly after `impl`.
25-
The order of generic parameters is restricted to lifetime parameters, then type parameters, and then const parameters.
25+
The order of generic parameters is restricted to lifetime parameters and then type and const parameters intermixed.
2626

2727
Some examples of items with type, const, and lifetime parameters:
2828

@@ -31,6 +31,7 @@ fn foo<'a, T>() {}
3131
trait A<U> {}
3232
struct Ref<'a, T> where T: 'a { r: &'a T }
3333
struct InnerArray<T, const N: usize>([T; N]);
34+
struct EitherOrderWorks<const N: bool, U>(U);
3435
```
3536

3637
Generic parameters are in scope within the item definition where they are

0 commit comments

Comments
 (0)