File tree 1 file changed +12
-2
lines changed
1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 2
2
3
3
> ** <sup >Syntax:<sup >** \
4
4
> _ ExternCrate_ :\
5
- >   ;  ; ` extern ` ` crate ` [ IDENTIFIER]   ; (` as ` ( [ IDENTIFIER] | ` _ ` ) )<sup >?</sup > ` ; `
5
+ >   ;  ; ` extern ` ` crate ` _ CrateRef_ _ AsClause_ <sup >?</sup > ` ; `
6
+ >
7
+ > _ CrateRef_ :\
8
+ >   ;  ; [ IDENTIFIER] | ` self `
9
+ >
10
+ > _ AsClause_ :\
11
+ >   ;  ; ` as ` ( [ IDENTIFIER] | ` _ ` )
6
12
7
13
An _ ` extern crate ` declaration_ specifies a dependency on an external crate.
8
14
The external crate is then bound into the declaring scope as the [ identifier]
9
- provided in the ` extern crate ` declaration.
15
+ provided in the ` extern crate ` declaration. The ` as ` clause can be used to
16
+ bind the imported crate to a different name.
10
17
11
18
The external crate is resolved to a specific ` soname ` at compile time, and a
12
19
runtime linkage requirement to that ` soname ` is passed to the linker for
@@ -16,6 +23,9 @@ the `crateid` attributes that were declared on the external crate when it was
16
23
compiled. If no ` crateid ` is provided, a default ` name ` attribute is assumed,
17
24
equal to the [ identifier] given in the ` extern crate ` declaration.
18
25
26
+ The ` self ` crate may be imported which creates a binding to the current crate.
27
+ In this case the ` as ` clause must be used to specify the name to bind it to.
28
+
19
29
Three examples of ` extern crate ` declarations:
20
30
21
31
``` rust,ignore
You can’t perform that action at this time.
0 commit comments