Description
https://docs.rs/hyper/0.14.7/hyper/client/conn/struct.Builder.html
Some libraries have trait bounds more complicated and more that one items, some of it could be automatically-derived or some could be specifically implemented for a certain structs/enums. Other libraries such as diesel also make use of trait bounds extensively.
pub fn handshake<T, B>(
&self,
io: T
) -> impl Future<Output = Result<(SendRequest<B>, Connection<T, B>)>> where
T: AsyncRead + AsyncWrite + Unpin + Send + 'static,
B: HttpBody + 'static,
B::Data: Send,
B::Error: Into<Box<dyn StdError + Send + Sync>>,
If the user wants to find out which type can they used within the trait bound. According to the context above that they want to find out what can they use for T
, they had to click on AsyncRead
, capture all the implementations in mind and then go back and click on AsyncWrite
and see which types appear again since trait bound is additive, it needs to satisfy all the traits.
If the user implemented a struct/enum that implemented all the specified trait bound then they know which is it, but if the user is using a third party library, chances are they will easily get lost or take some time to figure out what can T
be without implementing it themselves. Without examples of the function, it would be require some time to go through and understand all the traits and their respective implementations.
Maybe we could have a way for user to know what could possibly be the types that they can use for T
without going through the whole codebase? Behaving like goto implementation of language server, except now it can show what types satisfies all the specified trait bounds?
Of course the solution may not need to be perfect. I can think it may not work well with auto-traits since it could be hard to do that. Two solutions I can think of, we can have a implementations
section within the search tab that shows all the types that satisfies the trait bounds specified, like AsyncRead + AsyncWrite
(but not sure if we can also do it for Unpin
or Send
, maybe we couldn't cover lifetime at all). Another thing I can think of is that we can maybe provide some information when one clicks/hover on io
or T
then it will show the types that implement it, similar to the auto-traits section within the doc page.
Not sure if it is feasible, just an idea. Maybe we even had to have another search index if we can't reuse the existing one and not sure if it's worth it, or maybe we could make it lazily loaded only when they reached the tab. One issue I see is that types being shown may not be able to show standard library types and that may be an issue.