3 The `crate_type` attribute can be used to tell the compiler whether a crate is
4 a binary or a library (and even which type of library), and the `crate_name`
5 attribute can be used to set the name of the crate.
7 However, it is important to note that both the `crate_type` and `crate_name`
8 attributes have **no** effect whatsoever when using Cargo, the Rust package
9 manager. Since Cargo is used for the majority of Rust projects, this means
10 real-world uses of `crate_type` and `crate_name` are relatively limited.
13 // This crate is a library
14 #![crate_type = "lib"]
15 // The library is named "rary"
16 #![crate_name = "rary"]
18 pub fn public_function() {
19 println!("called rary's `public_function()`");
22 fn private_function() {
23 println!("called rary's `private_function()`");
26 pub fn indirect_access() {
27 print!("called rary's `indirect_access()`, that\n> ");
33 When the `crate_type` attribute is used, we no longer need to pass the
34 `--crate-type` flag to `rustc`.