#What are the reasons for using `extern crate foo` in `lib.rs`?
16 messages · Page 1 of 1 (latest)
couple years ago you had to do it for every crate, it's not needed in the latest edition
You can rename dependencies in your Cargo.toml:
[dependencies]
# allows using `use pem::Error;` in your code
pem = {version = "whatever", package = "pem-rfc7468"}
true, actually that + dep: prefixes probably eliminates all use cases for extern crate _ as _
so the only thing left is
#[macro_use]
extern crate log;
You should be able to import those macros with use
The examples in log's docs all use use to import its macros.
i prefer that style for sure
but many people just want the less obvious info! crate-wide without needing to import
really the only current use for extern crate is to bring in alloc in a no_std crate
oh and aliasing the current crate for some macros
?play ```rs
extern crate self as demo;
fn main() {
demo::main()
}
thread 'main' has overflowed its stack
fatal runtime error: stack overflow
timeout: the monitored command dumped core
/playground/tools/entrypoint.sh: line 15: 7 Aborted timeout --signal=KILL ${timeout} "$@"```
what macros other than proc macros?
proc macros 
The only usecase I know for extern crate self as blargh; is
to define a frontend crate that internally uses the proc macro that it re-exports.