extern crate

pull/66/head
Dhghomon 4 years ago committed by GitHub
parent b16f747f7a
commit 511e37cde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -11325,6 +11325,14 @@ fn main() {
And now it finally works, printing `[8, 9, 10], This won't work`. So you can see why Rust uses the prelude. But if you want, you don't need to use it. And you can even use `#![no_std]` (we saw this once) for when you can't even use something like stack memory. But most of the time you don't have to think about not using the prelude or `std` at all.
So why didn't we see the `extern` keyword before? It's because you don't need it that much anymore. Before, when bringing in an external crate you had to use it. So to use `rand` in the past, you had to write:
```rust
extern crate rand;
```
and then `use` statements for the mods, traits, etc. that you wanted to use. But the Rust compiler now doesn't need this help anymore - you can just use `use` and it knows where to find it. So you almost never need `extern crate` anymore, but in other people's Rust code you might still see it on the top.
### time

Loading…
Cancel
Save