cargo-public-api
cargo-public-api copied to clipboard
Present associated items as part of `impl`s
If a struct Foo
implements both e.g. TryFrom
and TryInto
, the output will contain
pub type some_crate::Foo::Error
pub type some_crate::Foo::Error
This is because both TryFrom
and TryInto
has an associated type called Error
.
The output should be more specific about where the Error
comes from in each case, to make it clear it is not a matter of duplication.
cargo doc HTML does not present these in isolation, but as part of impl
s. We show this:
% cd test-apis/example_api-v0.1.0
% cargo public-api --with-blanket-implementations
[...]
pub type example_api::Struct::Error = <U as TryFrom<T>>::Error
pub type example_api::Struct::Error = Infallible
i.e. the associated types are by themselves. That doesn't make them very "associated".
If we compare to cargo doc HTML, it looks like this:
% cargo doc --open

If you minimize an impl
, the Error
also goes away, and the impl
has a larger font. Clearly (but perhaps not obviously) the Error
is presented as part of an impl
. So I think the right way to solve this is to also include impl
s in our output. impl
s are also items, after all.
This is highly related to
- #36
- #38