From fc7fc90adfc9576507e730ab54f35d1073ab2a4f Mon Sep 17 00:00:00 2001 From: Tim Chevalier Date: Thu, 5 Apr 2012 16:26:36 -0700 Subject: [PATCH] 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. --- doc/tutorial.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/tutorial.md b/doc/tutorial.md index 66f3070de6c..6990d4574e9 100644 --- a/doc/tutorial.md +++ b/doc/tutorial.md @@ -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