@@ -1686,6 +1686,7 @@ purpose, you create a `.rc` crate file, which references any number of
1686
1686
1687
1687
~~~~ {.ignore}
1688
1688
#[link(name = "farm", vers = "2.5", author = "mjh")];
1689
+ #[crate_type = "lib"];
1689
1690
mod cow;
1690
1691
mod chicken;
1691
1692
mod horse;
@@ -1694,7 +1695,9 @@ mod horse;
1694
1695
Compiling this file will cause ` rustc ` to look for files named
1695
1696
` cow.rs ` , ` chicken.rs ` , ` horse.rs ` in the same directory as the ` .rc `
1696
1697
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.)
1698
1701
1699
1702
The ` #[link(...)] ` part provides meta information about the module,
1700
1703
which other crates can use to load the right module. More about that
@@ -1717,9 +1720,9 @@ content to the `poultry` module itself.
1717
1720
1718
1721
## Using other crates
1719
1722
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 ] .
1723
1726
1724
1727
[ std ] : http://doc.rust-lang.org/doc/std/index/General.html
1725
1728
0 commit comments