Trait labels in std docs

Recently I noticed this:

rustdoc apparently adds Read and Write labels at the top for types that implement std::io::Read and std::io::Write. Have I just not noticed this before, or is a somewhat new behavior?

Regardless, I like it. It wouldn't have occurred to me to check if VecDeque<u8> implements Read and Write. As it so happens, I was going to create read and write wrappers for exactly this purpose when I noticed the labels on VecDeque.

So how can I make use of these myself? I tried generating docs using nightly rustdoc for a crate of my own, which contains a type that implements Read and Write, but it did not generate the labels. Is this mechanism available to non-std crates?

It seems to be doc_notable_trait feature, check out the link for details.

You can mark some of your traits as notable and the types which implements it will have the label. But worth to know this feature is unstable yet and require unstable toolchain to work.

If you'd like to see such label for the external traits (like std::io::Read) which are implemented for your type, unfortunately, it didn't get it work.

For example, if I define such type:

pub struct MyReader;

impl Read for MyReader {
    fn read(
        &mut self,
        buf: &mut [u8],
    ) -> io::Result<usize> {
        // Just return 0 bytes read for testing
        Ok(0)
    }
}

I don't see the labels in docs:

But if I'll add some function/method which returns that type, I'll see some note about std::io::Read implementation for MyReader:

pub fn create_reader() -> MyReader {
    MyReader
}