11# Use declarations
22
3- > ** <sup >Syntax:<sup >**
3+ > ** <sup >Syntax:</ sup >**
44> _ UseDeclaration_ :
5- >   ;  ;   ;  ; ` use ` [ _ SimplePath_ ]   ; (` as ` [ IDENTIFIER] )<sup >?</sup > ` ; `
6- >   ;  ; | ` use ` ([ _ SimplePath_ ] <sup >?</sup > ` :: ` )<sup >?</sup > ` { ` _ UseDeclarationItems_ ` } ` ` ; `
7- >   ;  ; | ` use ` ([ _ SimplePath_ ] <sup >?</sup > ` :: ` )<sup >?</sup > ` * ` ` ; `
5+ >   ;  ; ([ _ Visibility_ ] )<sup >?</sup > ` use ` _ UseTree_ ` ; `
86>
9- > _ UseDeclarationItems_ :
10- >   ;  ; _ UseDeclarationItem_ ( ` , ` _ UseDeclarationItem_ )<sup >* </sup > ` , ` <sup >?<sup >
11- >
12- > _ UseDeclarationItem_ :
13- >   ;  ; ( ` self ` | [ IDENTIFIER] ) ( ` as ` [ IDENTIFIER] )<sup >?</sup >
7+ > _ UseTree_ :
8+ >   ;  ;   ;  ; ([ _ SimplePath_ ] <sup >?</sup > ` :: ` )<sup >?</sup > ` * `
9+ >   ;  ; | ([ _ SimplePath_ ] <sup >?</sup > ` :: ` )<sup >?</sup > ` { ` (_ UseTree_ ( ` , ` _ UseTree_ )<sup >* </sup > ` , ` <sup >?</sup >)<sup >?</sup > ` } `
10+ >   ;  ; | [ _ SimplePath_ ] ` as ` [ IDENTIFIER]
1411
1512A _ use declaration_ creates one or more local name bindings synonymous with
1613some other [ path] . Usually a ` use ` declaration is used to shorten the path
@@ -27,16 +24,17 @@ and [blocks], usually at the top.
2724
2825Use declarations support a number of convenient shortcuts:
2926
30- * Simultaneously binding a list of paths differing only in their final element,
31- using the glob-like brace syntax ` use a::b::{c,d,e,f}; `
32- * Simultaneously binding a list of paths differing only in their final element
33- and their immediate parent module, using the ` self ` keyword, such as `use
34- a::b : :{self, c, d};`
27+ * Simultaneously binding a list of paths with a common prefix, using the
28+ glob-like brace syntax ` use a::b::{c, d, e::f, g::h::i}; `
29+ * Simultaneously binding a list of paths with a common prefix and their common
30+ parent module, using the ` self ` keyword, such as ` use a::b::{self, c, d::e}; `
3531* Rebinding the target name as a new local name, using the syntax `use p::q::r
36- as x;` . This can also be used with the last two features: ` use a: : b : :{self as
37- ab, c as abc}`.
32+ as x;`. This can also be used with the last two features:
33+ ` use a::b::{self as ab, c as abc}` .
3834* Binding all paths matching a given prefix, using the asterisk wildcard syntax
39- ` use a::b::*; `
35+ ` use a::b::*; ` .
36+ * Nesting groups of the previous features multiple times, such as
37+ ` use a::b::{self as ab, c, d::{*, e::f}}; `
4038
4139An example of ` use ` declarations:
4240
@@ -126,3 +124,4 @@ fn main() {}
126124
127125[ IDENTIFIER ] : identifiers.html
128126[ _SimplePath_ ] : paths.html
127+ [ _Visibility_ ] : visibility-and-privacy.html
0 commit comments