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 for result::collect and option::collect should use boxed pointers and Vecs #14991

Closed
nathantypanski opened this issue Jun 18, 2014 · 3 comments · Fixed by #14992
Closed

Comments

@nathantypanski
Copy link
Contributor

They both follow basically the same format:

fn inc_conditionally(x: uint) -> Option<uint> {
    if x == uint::MAX { return None; }
    else { return Some(x+1u); }
}
let v = [1u, 2, 3];
let res = collect(v.iter().map(|&x| inc_conditionally(x)));
assert!(res == Some(~[2u, 3, 4]));

These should be updated to use box and Vec.

Edit:

  • Updated title to reflect below comment. No box was necessary.
@huonw
Copy link
Member

huonw commented Jun 18, 2014

This should just be updated to use Vec, no Box. ~[] was a single type that was entirely replaced by Vec. (i.e it was not equivalent to ~T with T= [].)

@nathantypanski
Copy link
Contributor Author

@huonw

:( right, there's no Box necessary anymore. Just Vec. I got it right in the code, but I wonder if I should reword the commit about it.

@nathantypanski
Copy link
Contributor Author

Reworded and resubmitted as mentioned.

nathantypanski added a commit to nathantypanski/rust that referenced this issue Jun 18, 2014
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
bors added a commit that referenced this issue Jun 18, 2014
This updates the documentation for result::collect() and
option::collect() to use the new-style syntax for owned pointers and
vectors.

closes #14991
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

Successfully merging a pull request may close this issue.

2 participants