Document direct implementations on type aliases.
This improves #32077, but is not a complete fix. For a type alias `type
NewType = AliasedType`, it will include any `impl NewType` and `impl
Trait for NewType` blocks in the documentation for `NewType`.
A complete fix would include the implementations from the aliased type
in the type alias' documentation, so that users have a complete
picture of methods that are available on the alias. However, to do this
properly would require a fix for #14072, as the alias may affect the
type parameters of the type alias, making the documentation difficult to
understand. (That is, for `type Result = std::result::Result<(), ()>` we
would ideally show documentation for `impl Result<(), ()>`, rather than
generic documentation for `impl<T, E> Result<T, E>`).
I think this improvement is worthwhile, as it exposes implementations
which are not currently documented by rustdoc. The documentation for the
implementations on the aliased type are still accessible by clicking
through to the docs for that type. (Although perhaps it's now less
obvious to the user that they should click-through to get there).
2017-05-16 01:16:44 -05:00
|
|
|
pub trait MyTrait {
|
|
|
|
fn method_on_mytrait() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct MyStruct;
|
|
|
|
|
|
|
|
impl MyStruct {
|
|
|
|
pub fn method_on_mystruct() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
// @has typedef/type.MyAlias.html
|
2023-01-28 17:35:02 -06:00
|
|
|
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyAlias'
|
|
|
|
// @has - '//*[@class="impl"]//h3[@class="code-header"]' 'impl MyTrait for MyAlias'
|
2022-08-10 15:13:18 -05:00
|
|
|
// @hasraw - 'Alias docstring'
|
Simplify and unify rustdoc sidebar styles
This switches to just use size, weight, and spacing to distinguish
headings in the sidebar. We no longer use boxes, horizontal bars, or
centering to distinguish headings. This makes it much easier to
understand the hierarchy of headings, and reduces visual noise.
I also refactored how the mobile topbar works. Previously, we tried to
shift around elements from the sidebar to make the topbar. Now, the
topbar gets its own elements, which can be styled on their own. This
makes styling and reasoning about those elements simpler.
Because the heading font sizes are bigger, increase the sidebar width
slightly.
As a very minor change, removed version from the "All types" page. It's
now only on the crate page.
2022-01-06 18:48:24 -06:00
|
|
|
// @has - '//*[@class="sidebar"]//*[@class="location"]' 'MyAlias'
|
2020-05-05 06:48:47 -05:00
|
|
|
// @has - '//*[@class="sidebar"]//a[@href="#implementations"]' 'Methods'
|
|
|
|
// @has - '//*[@class="sidebar"]//a[@href="#trait-implementations"]' 'Trait Implementations'
|
Document direct implementations on type aliases.
This improves #32077, but is not a complete fix. For a type alias `type
NewType = AliasedType`, it will include any `impl NewType` and `impl
Trait for NewType` blocks in the documentation for `NewType`.
A complete fix would include the implementations from the aliased type
in the type alias' documentation, so that users have a complete
picture of methods that are available on the alias. However, to do this
properly would require a fix for #14072, as the alias may affect the
type parameters of the type alias, making the documentation difficult to
understand. (That is, for `type Result = std::result::Result<(), ()>` we
would ideally show documentation for `impl Result<(), ()>`, rather than
generic documentation for `impl<T, E> Result<T, E>`).
I think this improvement is worthwhile, as it exposes implementations
which are not currently documented by rustdoc. The documentation for the
implementations on the aliased type are still accessible by clicking
through to the docs for that type. (Although perhaps it's now less
obvious to the user that they should click-through to get there).
2017-05-16 01:16:44 -05:00
|
|
|
/// Alias docstring
|
|
|
|
pub type MyAlias = MyStruct;
|
|
|
|
|
|
|
|
impl MyAlias {
|
|
|
|
pub fn method_on_myalias() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl MyTrait for MyAlias {}
|