Here's a fun trick. If we have Eyra re-export std, then users can use it as std = { package = "eyra", version = "..." }, which takes over the implied extern crate std;, so it gets pulled in without users having to add any extra code to their source files.
The result is, extern crate eyra; is no longer needed!
One downside is that there's no flag to cargo add for adding the package = "eyra" part, so it is necessary to add that dependency by hand. On the other hand, it means you don't need to edit src/main.rs by hand. Or examples/* and tests/* and so on. So now we're down to just two edits needed to use Eyra.
The extern crate eyra; approach still works. But overall this new approach seems convenient enough to present it as the default.
Here's a fun trick. If we have Eyra re-export
std
, then users can use it asstd = { package = "eyra", version = "..." }
, which takes over the impliedextern crate std;
, so it gets pulled in without users having to add any extra code to their source files.The result is,
extern crate eyra;
is no longer needed!One downside is that there's no flag to
cargo add
for adding thepackage = "eyra"
part, so it is necessary to add that dependency by hand. On the other hand, it means you don't need to editsrc/main.rs
by hand. Orexamples/*
andtests/*
and so on. So now we're down to just two edits needed to use Eyra.The
extern crate eyra;
approach still works. But overall this new approach seems convenient enough to present it as the default.