Linking to similar methods in the documentation

I believe the std documentation would benefit from having in each method a line listing similar methods. Perhaps I am a bit of a fool, but I have found myself a moment ago writing .enumerate().find_map(...) because I did not find the .position() method, which could have been linked in the find entry. Another notable example would be to link Result::{err,unwrap_err} to each other. Certainly I had this same thought several times before.

Does anyone else feel the same?

3 Likes

Sure. I don't think there would be many objections to adding cases like these to the documentation. I could see the docs for unwrap having a line "For unwrapping the error variant, see [unwrap_err]." or something similar.

You (or anyone) could create a PR for this.

Some things like this are in clippy -- see, for example, https://rust-lang.github.io/rust-clippy/master/index.html#filter_next -- so you could probably add more combinations that could be simplified. (Maybe not the find_map one, though, since that would require understanding the closure.)

But definitely quick things like "If you need the index of the found element, see position." sound like good doc additions to me. PRs welcome!

2 Likes