What if Cargo allowed you to write one "/
" in the name of a dependency? When resolving the dependency's name, it replaces it with "-
". When choosing the rustc
-visible name of the resulting library, it drops it and everything before it.
I recently started a pet project that, for reasons, is divided into lots of crates. In order to not pull a WindowsBunny in the event I publish this on crates.io, it uses crate names like remu-nintendo-dmg-01
and remu-sharp-lr35902
, which are long and annoying. I'd much rather use dmg-01
and lr35902
, but no, I'm not here to beat this dead horse.
Anyway, it occurred to me that the real problem here is that I want a nice, long, fully-qualified name for the global crate index, but I want a short name without all the (90% of the time) superfluous gunk when I'm actually using it, and without the need to incessantly rename the crate everywhere I use it (which was part of the reason I argued against the special case for "-
" in crate names).
So... what if Cargo understood a short-hand syntax for renaming crates within the manifest that gives us both? Let's say I changed the dependencies for the above into "remu-nintendo/dmg-01"
and "remu-sharp/lr35902"
. Rust itself would see them as dmg_01
and lr35902
: nice and short. crates.io would see them as remu-nintendo-dmg-01
and remu-sharp-lr35902
.
I think this would be good to have because it encourages people to "fake namespace" their crates in a way that avoids the inconvenience of the long names in code. Collections of crates like imag
, imag-store
, imag-tag
, etc., or piston2d-*
are more usable and less repetitive, and it lowers the incentives for unprefixed crate spamming.
Don't get me wrong, I still think Cargo should let me rename dependencies from the manifest arbitrarily, but this seems like a broad, common case.