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

change ~[] -> Vec for collect() #14992

Merged
merged 1 commit into from Jun 18, 2014
Merged

Conversation

nathantypanski
Copy link
Contributor

This updates the documentation for result::collect() and
option::collect() to use the new-style syntax for owned pointers and
vectors.

closes #14991

@nathantypanski nathantypanski changed the title change ~[] -> Box<Vec> for collect() change ~[] -> Vec for collect() Jun 18, 2014
/// else { return Some(x + 1); }
/// }
/// let v = vec!(1u, 2u);
/// let res: Option<Vec<uint>> = collect(v.iter().map(inc_conditionally));
Copy link
Member

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.

@huonw
Copy link
Member

huonw commented Jun 18, 2014

Also, neither of these examples are being tested automatically; I guess it might be because rustdoc needs them in fenced form (@alexcrichton, did this change recently? Was it meant to change?), could you change them so they don't go out of date again:

```rust
fn inc_conditionally(...)
...
```

@nathantypanski
Copy link
Contributor Author

Sure, I'll update as mentioned.

@nathantypanski
Copy link
Contributor Author

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;
Copy link
Member

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.

Copy link
Contributor Author

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.

@nathantypanski
Copy link
Contributor Author

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
bors added a commit that referenced this pull request 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
@bors bors closed this Jun 18, 2014
@bors bors merged commit feceb12 into rust-lang:master Jun 18, 2014
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 this pull request may close these issues.

Docs for result::collect and option::collect should use boxed pointers and Vecs
3 participants