mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
Documentation only: update tutorial to mention --lib only for single source files
In the tutorial, use the crate_type attribute when discussing crate files that are libraries, and only refer to the --lib files when talking about making a single source file into a library. Closes #2070.
This commit is contained in:
parent
b91c9f803d
commit
fc7fc90adf
@ -1686,6 +1686,7 @@ purpose, you create a `.rc` crate file, which references any number of
|
||||
|
||||
~~~~ {.ignore}
|
||||
#[link(name = "farm", vers = "2.5", author = "mjh")];
|
||||
#[crate_type = "lib"];
|
||||
mod cow;
|
||||
mod chicken;
|
||||
mod horse;
|
||||
@ -1694,7 +1695,9 @@ mod horse;
|
||||
Compiling this file will cause `rustc` to look for files named
|
||||
`cow.rs`, `chicken.rs`, `horse.rs` in the same directory as the `.rc`
|
||||
file, compile them all together, and, depending on the presence of the
|
||||
`--lib` switch, output a shared library or an executable.
|
||||
`crate_type = "lib"` attribute, output a shared library or an executable.
|
||||
(If the line `#[crate_type = "lib"];` was omitted, `rustc` would create an
|
||||
executable.)
|
||||
|
||||
The `#[link(...)]` part provides meta information about the module,
|
||||
which other crates can use to load the right module. More about that
|
||||
@ -1717,9 +1720,9 @@ content to the `poultry` module itself.
|
||||
|
||||
## Using other crates
|
||||
|
||||
Having compiled a crate with `--lib`, you can use it in another crate
|
||||
with a `use` directive. We've already seen `use std` in several of the
|
||||
examples, which loads in the [standard library][std].
|
||||
Having compiled a crate that contains the `#[crate_type = "lib"]` attribute,
|
||||
you can use it in another crate with a `use` directive. We've already seen
|
||||
`use std` in several of the examples, which loads in the [standard library][std].
|
||||
|
||||
[std]: http://doc.rust-lang.org/doc/std/index/General.html
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user