Skip to content

rustdoc: Include (or link to) methods "inherited" through auto-deref #19190

Closed
@mbrubeck

Description

@mbrubeck

Based on new-user questions on IRC, many users are confused by the fact that this is valid code:

let v: Vec<int> = vec![1,2,3];
let i = v.head();

even though the Vec<T> documentation does not include a method named head. This is because head is actually a method on type [T], and Vec<T> implements Deref<[T]>.

More generally, it's not easy (1) to look at the documentation for a given type and see all the methods that are callable on values of that type, or (2) to look at a piece of code and figure out where to find the documentation for a given method.

This could be fixed by listing "T methods callable via dereference" on the documentation page for a any type that implements Deref<T>. (This is similar to how systems like JavaDoc list "methods inherited from BaseClass" in the docs for any class that extends BaseClass.)

Metadata

Metadata

Assignees

Labels

P-mediumMedium priorityT-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions