-
Notifications
You must be signed in to change notification settings - Fork 13.3k
change ~[] -> Vec for collect() #14992
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
Conversation
/// else { return Some(x + 1); } | ||
/// } | ||
/// let v = vec!(1u, 2u); | ||
/// let res: Option<Vec<uint>> = collect(v.iter().map(inc_conditionally)); |
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.
I personally prefer the closure form, rather than inc_conditionally
taking a reference, since I think it's clearer what is happening.
Also, neither of these examples are being tested automatically; I guess it might be because
|
Sure, I'll update as mentioned. |
Done; the tests for these docs run now and they pass. |
/// let res = collect(v.iter().map(|&x| inc_conditionally(x))); | ||
/// assert!(res == Some(~[2u, 3, 4])); | ||
/// ```rust | ||
/// use std::option::collect; |
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 convention is for functions to be used module-qualified, i.e. import std::option
and call option::collect
.
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.
Updated as noted. Thanks for the style tip.
Oh, I missed the bit about closure form. I might as well go all-out and update it, rather than doing it halfway a hundred times. |
This updates the documentation for result::collect() and option::collect() to use the new-style syntax for vectors, instead of the old ~[]. Also updates the code blocks for these docs so they will be tested automatically. closes rust-lang#14991
This updates the documentation for result::collect() and option::collect() to use the new-style syntax for owned pointers and vectors. closes #14991
This updates the documentation for result::collect() and
option::collect() to use the new-style syntax for owned pointers and
vectors.
closes #14991