3 ms·
Unlike the way some languages' package systems work, Rust crates don't cleanly separate the public interface from the private implementation. In practice a cra
by mjw1007 3y ago
Unlike the way some languages' package systems work, Rust crates don't cleanly separate the public interface from the private implementation.
In practice a crate's public interface is effectively scattered throughout a number of modules. There's no separate textual interface definition that you could diff to see what you changed without also seeing changes to the implementation. Clients importing your library compile against the whole source.
So in practice if you want to check whether you changed your public interface unintentionally, your best bet is to compare the old and new output of Rust's automated documentation system, which by default is describing only the public interface.
Cargo-semver-checks attempts to automate that.
- obi1kenobi 3y agoNice summary! I'd also add that part of the public interface you're on the hook for is never explicitly written down in the source code, and is instead derived automatically by the compiler based on a set of rules. There are excellent reasons why this is the case, but as you could imagine this doesn't make semver any easier. For Rust folks, I'm talking about auto traits like Send and Sync. More info and examples here: https://predr.ag/blog/toward-fearless-cargo-update/ https://predr.ag/blog/toward-fearless-cargo-update/