mirror of
https://github.com/darkicewolf50/RustBrock.git
synced 2025-07-07 03:27:13 -06:00
finished ch 7.4
This commit is contained in:
25
Packages.md
25
Packages.md
@ -8,4 +8,27 @@ packages can have as many binary crates as you want but only at most one library
|
||||
|
||||
packages must have at least one crate
|
||||
|
||||
packages are defined by the toml file that comes with creating a new crate
|
||||
packages are defined by the toml file that comes with creating a new crate
|
||||
|
||||
# External Packages
|
||||
|
||||
These crates are normally found on [crates.io](https://crates.io/)
|
||||
in the guessing game the external crate was first defined in the cargo.toml as
|
||||
```toml
|
||||
rand = "0.8.5"
|
||||
```
|
||||
|
||||
it was then brough into scope by
|
||||
```rust
|
||||
use rand::Rng;
|
||||
// and then used
|
||||
rand::thread_rng().gen_range(0..=100);
|
||||
```
|
||||
|
||||
pulling other modules is often the same process
|
||||
|
||||
the std library is an external package but it doesn't need to be specified in the toml file
|
||||
|
||||
but it does need to be brought into scope with the ``use`` keyword
|
||||
|
||||
the std::other_part is an absolute path starting with std for the standard library crate
|
Reference in New Issue
Block a user