]> git.proxmox.com Git - rustc.git/blob - src/doc/rust-by-example/src/crates.md
New upstream version 1.41.1+dfsg1
[rustc.git] / src / doc / rust-by-example / src / crates.md
1 # Crates
2
3 A crate is a compilation unit in Rust. Whenever `rustc some_file.rs` is called,
4 `some_file.rs` is treated as the *crate file*. If `some_file.rs` has `mod`
5 declarations in it, then the contents of the module files would be inserted in
6 places where `mod` declarations in the crate file are found, *before* running
7 the compiler over it. In other words, modules do *not* get compiled
8 individually, only crates get compiled.
9
10 A crate can be compiled into a binary or into a library. By default, `rustc`
11 will produce a binary from a crate. This behavior can be overridden by passing
12 the `--crate-type` flag to `lib`.