-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add dedicated docstrings to Sum/Product impl of Result #42570
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
r? @frewsxcv -- documentation PR |
src/libcore/iter/traits.rs
Outdated
/// elements are taken, and the `Err` is returned. Should no `Err` occur, | ||
/// the sum of all elements is returned. | ||
/// | ||
/// Here is an example which sums up every integer in a vector, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per rust-lang/rfcs#1574, there should be an # Examples
line before this line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
src/libcore/iter/traits.rs
Outdated
/// if x < 0 { Err("Negative element found") } | ||
/// else { Ok(x) } | ||
/// ).sum(); | ||
/// assert!(res == Ok(3)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_eq!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
/// let v = vec![1, 2]; | ||
/// let res: Result<i32, &'static str> = v.iter().map(|&x: &i32| | ||
/// if x < 0 { Err("Negative element found") } | ||
/// else { Ok(x) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your change from https://github.com/rust-lang/rust/pull/42569/files could be copied here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, it's not so easy to apply here. Suggestion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah you're right, nevermind
(and fix a minor grammar typo below)
@bors r+ rollup Thanks! |
📌 Commit 2366c46 has been approved by |
Add dedicated docstrings to Sum/Product impl of Result (and fix a minor grammar typo below)
☀️ Test successful - status-appveyor, status-travis |
(and fix a minor grammar typo below)