When I started learning Rust, I saw
extern crate <crate>in a lot of code. Sometime annontated with
#[macro_use] and sometimes not and it confused me.
use is quite easy to understand coming from another language, because it is similar to
import statements in other languages.
extern crate has no equivalent in other languages that I know of and it was confusing why it is needed when you also have to add the crate to
It took a bit of googling to find out that as of Rust 2018 it is never required except for "internal" crates like
test. And as far as I can tell
#[macro_use] is never needed anymore.
Why do so many examples in the Rust books and crate documentation still use this? Are people still using Rust 2015? Did they not notice that it is not needed anymore? Or is it just legacy that nobody had the time to update? Clippy doesn't even have a lint for it, which I think is surprising considering these statements are just superfluous and confusing to newcomers.
Can somebody please explain this? Am I missing something obvious?