Is there a playground for crates.io. A place to practice and experiment with publishing crates. I want to publish something, but want to practice with a dummy crate. Or do first timers just practice on crates.io?
If you want to minimize formal mistakes before publishing:
Read your README.md file e.g. on github, see if links work properly, etc[1] (and that links aren’t github-internal relative links either)… because the README file is displayed on the crates.io page.
Use the cargo docs-rs
,[2] see if that build, and look through the resulting documentation, make it more unlikely that documentation will fail to build.
If you want to publish something not quite to crates.io yet, but experiment with using it as a dependency already, note that git dependencies are a thing.
Of course, if you use any cfg(feature = …)
, double-check your crate builds in various feature
configurations; also try documenting in different configurations; and make sure you haven’t left any tests not passing.
Fill out meta information in the Cargo.toml
if you haven’t already. And look through other crates’ repositories to compare how they’re doing it, what their Cargo.toml
or documentation or project structure looks like.
(I don’t know much about CI, or automating [parts of] the publishing process, but AFAIK, there’s many possibilities in those directions, too.)
If you’re worried about burning version numbers too quickly with mistakes anyway, there’s also the possibility of publishing a crate with a pre-release version number. Admitted, those are permanent, too, and always will stay listed in the crate’s history. Similarly, there’s 0.0.*
versions which aren’t super relevant (at least for ordinary crates that want stable-ish APIs eventually, because 0.0.*
doesn’t allow any non-breaking point releases anyway).
Of course also read
Publishing on crates.io - The Cargo Book
and feel free to take your time inspecting the contents of the package, as described there, before actually uploading it.
if you create links that link to items in your crate on
docs.rs
that’s a bit of a bootstrapping issue; i.e. you can predict the link they will be at, but unfortunately you can’t properly test it fully in advance ↩︎install the tool with
--locked
because it otherwise doesn’t build currently; execute it with a localrustup override set nightly
enabled, becausecargo +nightly docs-rs
doesn’t seem to work ↩︎
I enable all lints from clippy in the cargo
group. It will warn you about missing metadata and such.
There are also tools like [cargo-all-features](https://github.com/frewsxcv/cargo-all-features) that can automatically build and test all combinations of features.