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

Improve docs for collecting into `Option`s #56342

Open
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@killercup
Member

killercup commented Nov 29, 2018

Changes the original example to use more idiomatic formatting as well
as .checked_add. Also adds a second example to show a case where the
.collect returns None.

Improve docs for collecting into `Option`s
Changes the original example to use more idiomatic formatting as well
as `.checked_add`. Also adds a second example to show a case where the
`.collect` returns `None`.
@rust-highfive

This comment has been minimized.

Collaborator

rust-highfive commented Nov 29, 2018

r? @bluss

(rust_highfive has picked a reviewer for you, use r? to override)

///
/// let res: Option<Vec<u16>> = items
/// .iter()
/// .map(|x| x.checked_add(1))

This comment has been minimized.

@killercup

killercup Nov 29, 2018

Member

Not sure if this is an obvious function or should be explain more (or use the explicit impl of checked adding as it did previously)

This comment has been minimized.

@bluss

bluss Dec 9, 2018

Contributor

It seems fine as it is, maybe it comes best together if we mention that checked_add/_sub returns None on overflow, on this example or the next?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment