Skip to content

Commit b36ce30

Browse files
committed
Document extern_crate_self
1 parent db4f1f2 commit b36ce30

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/items/extern-crates.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22

33
> **<sup>Syntax:<sup>**\
44
> _ExternCrate_ :\
5-
> &nbsp;&nbsp; `extern` `crate` [IDENTIFIER]&nbsp;(`as` ( [IDENTIFIER] | `_` ) )<sup>?</sup> `;`
5+
> &nbsp;&nbsp; `extern` `crate` ( [IDENTIFIER] | `self` ) (`as` ( [IDENTIFIER] | `_` ) )<sup>?</sup> `;`
66
77
An _`extern crate` declaration_ specifies a dependency on an external crate.
88
The external crate is then bound into the declaring scope as the [identifier]
9-
provided in the `extern crate` declaration.
9+
provided in the `extern crate` declaration. The `as` clause can be used to
10+
bind the imported crate to a different name.
1011

1112
The external crate is resolved to a specific `soname` at compile time, and a
1213
runtime linkage requirement to that `soname` is passed to the linker for
@@ -16,6 +17,9 @@ the `crateid` attributes that were declared on the external crate when it was
1617
compiled. If no `crateid` is provided, a default `name` attribute is assumed,
1718
equal to the [identifier] given in the `extern crate` declaration.
1819

20+
The `self` crate may be imported which creates a binding to the current crate.
21+
In this case the `as` clause must be used to specify the name to bind it to.
22+
1923
Three examples of `extern crate` declarations:
2024

2125
```rust,ignore

0 commit comments

Comments
 (0)