I understand that I can use the cfg_attr
attribute to conditionally derive Trait implementations for types. For example, A struct MyStruct
which always implements Clone
, Copy
, and Debug
, but which implements PartialEq
if and only if the my-feature
feature is enabled, can be defined as follows:
#[derive(Clone, Copy, Debug)]
#[cfg_attr(feature = "my-feature", derive(PartialEq)]
struct MyStruct;
But is it possible to make the generated documentation reflect this? I would like the rustdoc
-generated documentation to state that PartialEq
is implemented for MyStruct
if and only if the my-feature
feature is enabled.
So far, I have only accomplished two outcomes, neither of which I want:
- If I compile the docs with the
my-feature
feature enabled, the generated documentation just says thatMyStruct
implementsPartialEq
, with no mention of feature gating - If I compile the docs without the
my-feautre
feature enabled, generated documentation does not indicate thatPartialEq
is or can be implemented forMyStruct
.