Add guide-level section on the trailing comma

As with other lists of generic arguments in Rust, the grammar for
`use<..>` specifiers supports an optional trailing comma.  This is
already specified in the formal grammar, but let's also note this in
the guide-level section.

(Thanks to Josh Triplett for raising this point.)
This commit is contained in:
Travis Cross 2024-04-26 07:23:25 +00:00
parent 26911c8b30
commit 9fbce80d84
1 changed files with 9 additions and 0 deletions

View File

@ -162,6 +162,15 @@ The `use<..>` specifier applies to the entire `impl Trait` opaque type. In cont
fn foo<T>(_: T) -> impl use<T> for<'a> FnOnce(&'a ()) { |&()| () }
```
## Optional trailing comma
As with other lists of generic arguments in Rust, a trailing comma is optional in `use<..>` specifiers:
```rust
fn foo1<T>(_: T) -> impl use<T> Sized {} //~ OK.
fn foo2<T>(_: T) -> impl use<T,> Sized {} //~ Also OK.
```
# Reference-level explanation
[reference-level-explanation]: #reference-level-explanation