-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Description
Hi. I'm not sure if it's right to call this a bug, but it is a thing that can be quite confusing (and time-consuming to resolve via the docs rather than via an IDE) so I thought I would file an issue.
The problem can be seen in gitlab::api, for example. Consider this quote from the top level example on docs.rs:
let client = Gitlab::new("gitlab.com", "private-token").unwrap();
let endpoint = projects::Project::builder().project("gitlab-org/gitlab").build().unwrap();
let project: Project = endpoint.query(&client).unwrap();Suppose the user wants to know what this query method is. They navigate to the docs for project::Project (since that is the return type from the builder),
Searching that page does not reveal any methods called query. Nor is looking at the trait impls in the left sidebar particularly illuminating. Perhaps the programmer will spot that endpoint in the code is likely to be the Endpoint. Clicking through to the endpoint trait gets a page which shows various methods. No mention of a query method.
In fact, the query method is on the extension trait Query which is relevant because:
impl<E, T, C> Query<T, C> for E where
E: Endpoint,
T: DeserializeOwned,
C: Client,
It would be really nice if it would be possible to use Rustdoc output to find all the methods for a struct.
I tried to find an example in the standard library, but it wasn't so easy. The standard libray doesn't have many of these trait extension traits. The most obvious one is ToString which does seem to get its to_string method into all the places I looked. Likewise ToOwned (which is impl for T: Clone).
I confess I probably don't appreciate what the downsides would be of such a change, or how hard it might be, or, why the gitlab crate output is different from the stdlib output. I hope this report is helpful anyway. Thanks.