Skip to content

Commit

Permalink
Document extern_crate_self
Browse files Browse the repository at this point in the history
  • Loading branch information
ehuss committed Jan 27, 2019
1 parent ec8bb56 commit 085f0a8
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/items/extern-crates.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

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

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

The `self` crate may be imported which creates a binding to the current crate.
In this case the `as` clause must be used to specify the name to bind it to.

Three examples of `extern crate` declarations:

```rust,ignore
Expand Down

0 comments on commit 085f0a8

Please sign in to comment.