rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
98.38k stars 12.72k forks source link

It's not possible to search for specialized generics in docs #99874

Open mqudsi opened 2 years ago

mqudsi commented 2 years ago

It should be possible to search for types implementing/using a particular specialization of a generic, as these specializations are already broken down and available either in the prototype/declaration (for parameters to and return values of functions) or in the "trait implementations" section (for specific trait implementations).

e.g. I should be able to search the rust docs for the literal string AsRef<[u8]> and get back any types implementing AsRef<[u8]>.

Some catches:

@rustbot label +A-docs -C-bug +C-feature-request

GuillaumeGomez commented 2 years ago

Simply remove the []. You can search for AsRef<u8>, it'll pick the [u8] too.

mqudsi commented 2 years ago

Do [ and ] have special meaning to the search right now such that they can't be treated as literals?

GuillaumeGomez commented 2 years ago

They don't have any meaning.

mqudsi commented 2 years ago

I'm not sure if you want to discuss the other points in this issue or in a new issue, but the search results aren't really illuminating for trait implementations. The search for AsRef<u8> in the current nightly docs returns the following:

image

The first result (std::convert::AsRef) contains a trait implementation for AsRef<[u8]> (but not AsRef<u8> which is what I literally searched - just a note!) but the results overview isn't very illuminating. The results are mainly only for the AsRef trait itself, and don't showcase my search terms, and the results exclude types implementing the trait (I can get to primitive.str via AsRef thanks to cross-linking, but the search results themselves don't provide any context).

It would be nice if searching for a trait or a specialization of a trait also included (as another tab or via something else?) types that implemented that trait/specialization. It would also be really helpful if some sort of context could be shown in the results so that one doesn't have to then ctrl-f for the search terms after clicking on a result to see if it's what they actually want or not before going back to the search results list and trying another result.

I don't know if I'm approaching this the right way or if it's better for me to come up with some sort of concrete proposal for how I personally think the search results could show more context/be more immediately useful at a glance and don't mean to disparage any of the work that's already been put into the (excellent!) rustdocs already.