Skip to content

Commit fc7fc90

Browse files
committed
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.
1 parent b91c9f8 commit fc7fc90

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

doc/tutorial.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1686,6 +1686,7 @@ purpose, you create a `.rc` crate file, which references any number of
16861686

16871687
~~~~ {.ignore}
16881688
#[link(name = "farm", vers = "2.5", author = "mjh")];
1689+
#[crate_type = "lib"];
16891690
mod cow;
16901691
mod chicken;
16911692
mod horse;
@@ -1694,7 +1695,9 @@ mod horse;
16941695
Compiling this file will cause `rustc` to look for files named
16951696
`cow.rs`, `chicken.rs`, `horse.rs` in the same directory as the `.rc`
16961697
file, compile them all together, and, depending on the presence of the
1697-
`--lib` switch, output a shared library or an executable.
1698+
`crate_type = "lib"` attribute, output a shared library or an executable.
1699+
(If the line `#[crate_type = "lib"];` was omitted, `rustc` would create an
1700+
executable.)
16981701

16991702
The `#[link(...)]` part provides meta information about the module,
17001703
which other crates can use to load the right module. More about that
@@ -1717,9 +1720,9 @@ content to the `poultry` module itself.
17171720

17181721
## Using other crates
17191722

1720-
Having compiled a crate with `--lib`, you can use it in another crate
1721-
with a `use` directive. We've already seen `use std` in several of the
1722-
examples, which loads in the [standard library][std].
1723+
Having compiled a crate that contains the `#[crate_type = "lib"]` attribute,
1724+
you can use it in another crate with a `use` directive. We've already seen
1725+
`use std` in several of the examples, which loads in the [standard library][std].
17231726

17241727
[std]: http://doc.rust-lang.org/doc/std/index/General.html
17251728

0 commit comments

Comments
 (0)