From 75d473bb760e48a37c0abea69545987a5d8df97f Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Thu, 1 Feb 2018 21:52:56 +0100 Subject: [PATCH] Add mention of RFC 2128 (use_nested_groups) in the reference --- src/items/use-declarations.md | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/items/use-declarations.md b/src/items/use-declarations.md index bee94fadd..c13412458 100644 --- a/src/items/use-declarations.md +++ b/src/items/use-declarations.md @@ -1,16 +1,13 @@ # Use declarations -> **Syntax:** +> **Syntax:** > _UseDeclaration_ : ->       `use` [_SimplePath_] (`as` [IDENTIFIER])? `;` ->    | `use` ([_SimplePath_]? `::`)? `{` _UseDeclarationItems_ `}` `;` ->    | `use` ([_SimplePath_]? `::`)? `*` `;` +>    ([_Visibility_])? `use` _UseTree_ `;` > -> _UseDeclarationItems_ : ->    _UseDeclarationItem_ ( `,` _UseDeclarationItem_ )* `,`? -> -> _UseDeclarationItem_ : ->    ( `self` | [IDENTIFIER] ) ( `as` [IDENTIFIER] )? +> _UseTree_ : +>       ([_SimplePath_]? `::`)? `*` +>    | ([_SimplePath_]? `::`)? `{` (_UseTree_ ( `,` _UseTree_ )* `,`?)? `}` +>    | [_SimplePath_] `as` [IDENTIFIER] A _use declaration_ creates one or more local name bindings synonymous with some other [path]. Usually a `use` declaration is used to shorten the path @@ -27,16 +24,17 @@ and [blocks], usually at the top. Use declarations support a number of convenient shortcuts: -* Simultaneously binding a list of paths differing only in their final element, - using the glob-like brace syntax `use a::b::{c,d,e,f};` -* Simultaneously binding a list of paths differing only in their final element - and their immediate parent module, using the `self` keyword, such as `use - a::b::{self, c, d};` +* Simultaneously binding a list of paths with a common prefix, using the + glob-like brace syntax `use a::b::{c, d, e::f, g::h::i};` +* Simultaneously binding a list of paths with a common prefix and their common + parent module, using the `self` keyword, such as `use a::b::{self, c, d::e};` * Rebinding the target name as a new local name, using the syntax `use p::q::r - as x;`. This can also be used with the last two features: `use a::b::{self as - ab, c as abc}`. + as x;`. This can also be used with the last two features: + `use a::b::{self as ab, c as abc}`. * Binding all paths matching a given prefix, using the asterisk wildcard syntax - `use a::b::*;` + `use a::b::*;`. +* Nesting groups of the previous features multiple times, such as + `use a::b::{self as ab, c, d::{*, e::f}};` An example of `use` declarations: @@ -126,3 +124,4 @@ fn main() {} [IDENTIFIER]: identifiers.html [_SimplePath_]: paths.html +[_Visibility_]: visibility-and-privacy.html