Repository navigation
Description
Currently, the sidebar looks pretty monotonous and dull, difficult to navigate. For example: Primitive Type slice (1.99.1).
However, #154644 is definitely a step in the right direction. So I would suggest taking this initiative even further.
1. Split "Methods" into more distinct groups based on how self is passed.
- Immutable Methods (
&self) - Mutable Methods (
&mut self) - Consuming Methods (
self)
Or simpler (to preserve grouping of items like get() / get_mut()):
- Borrowing Methods (
&selfand&mut self) - Exclusive Methods (
self)
2. Highlight the following characteristics by category:
-
Safety
- safe
- safe but having raw pointers in any position, thus involving unsafe code
- explicitly
unsafe
-
Concreteness (excluding lifetimes!)
- common (e.g.
impl Foo for Bar) or generic only over parameters of the parent item, if any (e.g.impl<T> Foo for Bar<T>) - generic over additional type parameters introduced (e.g.
impl<T, U> Foo<U> for Bar<T>) - non-generic over some parameter of the parent item, or specialized over all of them
Likeimpl AsRef<[u8]> for str, as opposed to e.g.impl<T> AsRef<[T]> for [T]. - having any
constgeneric parameters
- common (e.g.
Given that only two categories are proposed, only the basic formatting properties can be used for them: color and font style.
Or it might also be worth employing subscript/superscript somehow here, idk.
| member | generic | special | w/ const | |
|---|---|---|---|---|
| safe | ||||
| w/ raw | ||||
unsafe |
Instead of hard-coding the color, it can just tint the primary theme color used for sidebar captions.
Activity
GuillaumeGomez commentedon Oct 25, 2026
I don't think introducing differentiation through colors or font style is a good idea. It adds a lot more things to be wary about for themes handling and for visually impaired people, it's just not something they will receive information about.
cher-nov commentedon Oct 26, 2026
@GuillaumeGomez Thanks for the feedback! Could you please also take a look at #133573, which is kinda similar?
That's not the only option. The other ones are icons, badges or additional characters - e.g. writing the generic function
foobarasfoobar<>.The issue is about distinction - I might know roughly what kind of routine I'm looking for, but the sidebar doesn't currently help me with that.
Sure, but I'd like to point out something:
The best solution for people with disabilities, IMO, is an accessibility theme specifically tailored to their needs such as screen readers.
Color is already being used at least to highlight the type name in the page header ("Primitive Type slice").
Previously, it was also a link, but not anymore. So, when all color is removed from the page, that emphasis is lost as well.
It would be anyway useful to have a page setting like "Mark subroutine specifics: none / by style / with syntax".
The number of colors could be reduced (color-blind people would appreciate this?), as well as categories. Like this, for example:
unsafe* non-highlighted text means the default theme color
[-]`rustdoc`: Legend for notable language specifics of items in the sidebar[/-][+]`rustdoc`: Legend for important language specifics of items in the sidebar[/+]