A crate is a compilation unit in Rust. Es una libreria/ejecutable (main) que tiene uno o mas mods
adentro. A crate is a compilation unit in Rust. Whenever rustc some_file.rs is called, some_file.rs is treated as the crate file. Hace como una “expansión de macros” previo a compilacion donde remplaza los mod nombre_del_mode; por su contenido (que se encuentra en otro archivo) → solo se compilan los crates, no los módulos.
A crate can come in one of two forms: a binary crate or a library crate.
Binary crates
are programs you can compile to an executable that you can run, such as a command-line program or a server. Each must have a function called main that defines what happens when the executable runs. All the crates we’ve created so far have been binary crates.
Library crates
don’t have a mainfunction, and they don’t compile to an executable. Instead, they define functionality intended to be shared with multiple projects.
A package is a bundle of one or more crates that provides a set of functionality. A package contains a Cargo.toml file that describes how to build those crates.
If a package contains src/main.rs and src/lib.rs, it has two crates: a binary and a library, both with the same name as the package. A package can have multiple binary crates by placing files in the src/bin directory: each file will be a separate binary crate.