Rust crate naming tip: use hyphens not underscores. Hyphens are idiomatic and Cargo does the conversion to underscore in your Rust code automatically.
Why are hyphens idiomatic? What's the benefit that makes it worth every rust user having to learn this extra thing, vs. just saying underscores are idiomatic?
-
-
Consistency. Nearly all crates use hyphens, so it is easier to recommend to continue to do that rather than trying to boil the ocean of making every crate change. Also hyphens are common in other ecosystems.
-
Ahh, interesting point. So the convention is already hyphens, so there'd be more mental load if we tried to switch now and then half the crates were hyphens and half underscores. Makes sense, thanks!
- 1 more reply
New conversation -
-
-
Also, there is nothing really to learn - you just do what everyone else is doing and everything just works.
-
As a crate user I have to remember to add `bit-vec` to Cargo.toml, but `extern crate bit_vec` in the file. That they aren't the same is not exactly intuitive. `cargo add bit_vec` works though, which makes it easier. A better error message for `extern crate bit-vec` would be
. - 1 more reply
New conversation -
-
-
I think part of this is based on how the crate name will often appear in urls. With dns having _ be illegal, it looks wonky having - on the left side and _ to the right of the first /
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.