File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 22
33> ** <sup >Syntax:<sup >** \
44> _ 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] | ` _ ` )
612
713An _ ` extern crate ` declaration_ specifies a dependency on an external crate.
814The 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.
1017
1118The external crate is resolved to a specific ` soname ` at compile time, and a
1219runtime 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
1623compiled. If no ` crateid ` is provided, a default ` name ` attribute is assumed,
1724equal to the [ identifier] given in the ` extern crate ` declaration.
1825
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+
1929Three examples of ` extern crate ` declarations:
2030
2131``` rust,ignore
You can’t perform that action at this time.
0 commit comments