-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Demo FromIterator
short-circuiting
#59362
Demo FromIterator
short-circuiting
#59362
Conversation
…` and early termination.
r? @dtolnay (rust_highfive has picked a reviewer for you, use r? to override) |
📌 Commit d5a61c0 has been approved by |
…ircuiting, r=Centril Demo `FromIterator` short-circuiting while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken." The code snippets provided here are meant to correct that.
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
@bors r- (r=me with @killercup's fix / green travis) |
Co-Authored-By: pnkfelix <pnkfelix@pnkfx.org>
add missing braces analogous to those suggested by killercup
/// further elements are taken from `iter` after the first `None`. | ||
/// | ||
/// ``` | ||
/// let items = vec![3_u16, 2, 1, 10]; |
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.
Just as a question from a relative newbie: What is this 3_u16
syntax? I have seen the 3u16
syntax but never with the underscore. Is there a difference between this syntax?
I would suggest that using 3u16
or even let items: Vec<u16>= vec![3, 2, 1, 10];
to make it more clear for people that are not too experienced with Rust. But that is just my humble opinion!
EDIT: Nice examples by the way! I never knew it worked this way :)
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.
The _
here is merely an effect of separators in numeric literals, e.g. 3_000_000_u32
or 3_000____u32
. The underscores are for readability and have no effect otherwise. 3u16
and 3_u16
are thus equivalent.
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.
Alright! Thanks for sharing! :)
@bors r+ rollup |
📌 Commit 0e83e96 has been approved by |
…ircuiting, r=Centril Demo `FromIterator` short-circuiting while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken." The code snippets provided here are meant to correct that.
…ircuiting, r=Centril Demo `FromIterator` short-circuiting while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken." The code snippets provided here are meant to correct that.
…ircuiting, r=Centril Demo `FromIterator` short-circuiting while looking at a FIXME in `FromIterator for Option` and `FromIterator for Result`, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken." The code snippets provided here are meant to correct that.
Rollup of 10 pull requests Successful merges: - #59150 (Expand suggestions for type ascription parse errors) - #59232 (Merge `Promoted` and `Static` in `mir::Place`) - #59267 (Provide suggestion when using field access instead of path) - #59315 (Add no_hash to query macro and move some queries over) - #59334 (Update build instructions in README.md) - #59362 (Demo `FromIterator` short-circuiting) - #59374 (Simplify checked_duration_since) - #59389 (replace redundant note in deprecation warning) - #59410 (Clarify `{Ord,f32,f64}::clamp` docs a little) - #59419 (Utilize `?` instead of `return None`.) Failed merges: r? @ghost
Rollup of 10 pull requests Successful merges: - #59150 (Expand suggestions for type ascription parse errors) - #59232 (Merge `Promoted` and `Static` in `mir::Place`) - #59267 (Provide suggestion when using field access instead of path) - #59315 (Add no_hash to query macro and move some queries over) - #59334 (Update build instructions in README.md) - #59362 (Demo `FromIterator` short-circuiting) - #59374 (Simplify checked_duration_since) - #59389 (replace redundant note in deprecation warning) - #59410 (Clarify `{Ord,f32,f64}::clamp` docs a little) - #59419 (Utilize `?` instead of `return None`.) Failed merges: r? @ghost
while looking at a FIXME in
FromIterator for Option
andFromIterator for Result
, I realized that the current documentation does not have example code showing exactly what is meant by "no further elements are taken."The code snippets provided here are meant to correct that.