Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Arguments are described in the reverse order for map_or and map_or_else #84608

Closed
lefth opened this issue Apr 27, 2021 · 1 comment
Closed

Comments

@lefth
Copy link
Contributor

lefth commented Apr 27, 2021

Result and Option have map_or and map_or_else functions. In each case, the first parameter is used when the struct contains no value (or contains an error), while the second parameter is used when there is a value in the struct. The documentation mentions there parameters in the reverse order. This is confusing, as programmers expect parameter names to be documented in order.

I suggest reversing the wording.

I'll be submitting a PR with the change. If there are other classes or functions that have this issue, please leave a comment and I will change them as well.

@lefth lefth changed the title Arguments are described in the reverse order for map_or and map_or_else Docs: Arguments are described in the reverse order for map_or and map_or_else Apr 27, 2021
lefth added a commit to lefth/rust that referenced this issue Apr 27, 2021
bors added a commit to rust-lang-ci/rust that referenced this issue Apr 27, 2021
Reorder the parameter descriptions of map_or and map_or_else

They were described backwards, probably leading users to write arguments in the wrong order. Bug: rust-lang#84608
@jyn514
Copy link
Member

jyn514 commented Apr 27, 2021

Fixed in #84609.

@jyn514 jyn514 closed this as completed Apr 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants