rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
96.69k stars 12.49k forks source link

Vec::iter not found in search in rustdoc #87128

Open pickfire opened 3 years ago

pickfire commented 3 years ago

In rust doc search, I can't find Vec::iter although iter is available in Vec.

https://doc.rust-lang.org/std/index.html?search=vec%3A%3Aiter

jyn514 commented 3 years ago

@pickfire it's there, it's just called slice::iter because it comes from the Deref impl.

Are you suggested rustdoc should show Deref methods in search? That seems useful, but a little complicated ... Search is already pretty buggy.

pickfire commented 3 years ago

Yeah, that would be good but do seemed a little bit complicated, the search for deref could have a lower score or shown with some sort of visual to know it's a Deref.

At least I didn't noticed that it's slice because the doc page is quite long and I don't know which function does it impl for. Quite a few times I wonder which impl I am looking at, scroll up tons of page and saw the wrong one.

notriddle commented 3 years ago

Adding an alias works, if it's acceptable to solve this as a one-off.

image

```diff diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index de25c984abf..e9966a418ef 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs @@ -701,6 +701,7 @@ pub fn reverse(&mut self) { /// assert_eq!(iterator.next(), Some(&4)); /// assert_eq!(iterator.next(), None); /// ``` + #[doc(alias = "Vec::iter")] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn iter(&self) -> Iter<'_, T> { @@ -718,6 +719,7 @@ pub fn iter(&self) -> Iter<'_, T> { /// } /// assert_eq!(x, &[3, 4, 6]); /// ``` + #[doc(alias = "Vec::iter_mut")] #[stable(feature = "rust1", since = "1.0.0")] #[inline] pub fn iter_mut(&mut self) -> IterMut<'_, T> { ```
jyn514 commented 3 years ago

Seems silly to do this for every single slice method. I think we should do this consistently if we do it at all.

pickfire commented 3 years ago

Yes, if we do it it should be added for everything that implements Deref for all types.

lolbinarycat commented 2 weeks ago

related/possible duplicate: #63080