Is it good practice to call crates "hello-world", "hello_world" or does it not matter?

I've seen both ways, e.g. https://crates.io/crates/handlebars-markdown-helper or https://crates.io/crates/elastic_types. I know I was confused the first time that a crate is called like handlebars-markdown-helper, but it is used like extern crate handlebars_markdown_helper. (However I was only confused the first time. It's not a problem for me now.)

2 Likes

The - to _ thing didn't always exist, so you'll see a lot of earlier projects use _. The convention is generally to use -.

1 Like

Thank you for your feedback. I'll point this out in my tutorial :slight_smile:

Based on @steveklabnik's comment I filed these two tickets to encourage hyphens. Cargo should allow dependencies to be specified using hyphens where the crate name contains underscores, and crates.io should display hyphens instead of underscores in all crate names in the UI.

https://github.com/rust-lang/cargo/issues/2775

https://github.com/rust-lang/crates.io/issues/350