Tool to compare public APIs?

Hi folks.

I have a crate, and I'm worried about backward compatibility when something is changed (e. g. when some type is moved to a different mod but still exported as the previous name).

It would be helpful to have a tool, which exports all signatures of all types and all functions in a simple format: one line — one signature.

So API changes could be inspected with a simple diff invocation.

Something like cargo doc, but much simpler. ( cargo doc uses public type names for displaying types).

I believe something like this already exists. What is this tool name?

2 Likes

I think all the public interfaces should have some test cases attached to it. Test is a necessary component for reliable software and also has side effect to prevent accidental api breakage.

It is not practically possible to use tests test to fix public API. Couple examples of situations which can rarely be discovered with tests:

  • type becomes accidentally reexported by two different names
  • functions lifetimes changed so that resulting lifetime becomes dependent on two parameters instead of one
  • function signature is changed so function parameters now requires type to be Sync
3 Likes

There's GitHub - rust-lang/rust-semverver: Automatic checking for semantic versioning in library crates, does that work for you?

5 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.