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

Add documentation examples for parallel iterator methods #466

Merged
merged 4 commits into from Nov 7, 2017

Conversation

Projects
None yet
3 participants
@mamuleanu
Copy link
Contributor

mamuleanu commented Oct 29, 2017

Closes #420

/// ```
/// use rayon::prelude::*;
/// let a = [-3_i32, 77, 53, 240, -1];
/// assert_eq!(*a.par_iter().min_by(|x, y| x.cmp(y)).unwrap(), -3);

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

assert_eq!(..., Some(-3))

/// ```
/// use rayon::prelude::*;
/// let a = [-3_i32, 34, 2, 5, -10, -3, -23];
/// assert_eq!(*a.par_iter().min_by_key(|x| x.abs()).unwrap(), 2);

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

Try to avoid unwrap, just like above.

/// ```
/// use rayon::prelude::*;
/// let a = [-3_i32, 77, 53, 240, -1];
/// assert_eq!(*a.iter().max_by(|x, y| x.cmp(y)).unwrap(), 240);

This comment has been minimized.

@lnicola
/// ```
/// use rayon::prelude::*;
/// let a = [-3_i32, 34, 2, 5, -10, -3, -23];
/// assert_eq!(*a.par_iter().max_by_key(|x| x.abs()).unwrap(), 34);

This comment has been minimized.

@lnicola
/// let a = [43, 77, 32];
/// assert_eq!(a.par_iter().count(), 3);
///
/// let a = [43, 77, 32, 39];

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

Having two identical examples is a bit overkill.

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

Maybe something like (1..100).into_par_iter().filter(|x| x % 2 == 1).count()?

/// ```
/// use rayon::prelude::*;
/// let a = [45, 74, 32];
/// let b: Vec<u32> = Vec::new();

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

Maybe let b = []; or let b: [i32] = [];?

/// ```
/// use rayon::prelude::*;
/// let a = [45, 74, 32];
/// let b: Vec<u32> = Vec::new();

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

Same as above, no need for a Vec.

/// use std::sync::mpsc::channel;
/// use rayon::prelude::*;
/// let (tx, rx) = channel();
/// (0..5).map(|x| x * 2 + 1).par_iter()

This comment has been minimized.

@lnicola

lnicola Oct 29, 2017

(0..5).into_par_iter().map(...). Right now there's no way to obtain a ParallelIterator from a general Iterator like map returns.

@cuviper

This comment has been minimized.

Copy link
Member

cuviper commented Nov 2, 2017

Thanks for the detailed review, @lnicola!

@mamuleanu will you be able to address this feedback? At a minimum, we need to get a clean CI build.

@mamuleanu

This comment has been minimized.

Copy link
Contributor Author

mamuleanu commented Nov 3, 2017

@cuviper Yes, I will update the examples by the end of the day.
Thanks for the review, @lnicola !

@mamuleanu mamuleanu force-pushed the mamuleanu:docs-updates branch from 557f2c9 to 913d358 Nov 4, 2017

@cuviper cuviper changed the title [WIP] Add documentation examples for parallel iterator methods Add documentation examples for parallel iterator methods Nov 6, 2017

@cuviper

This comment has been minimized.

Copy link
Member

cuviper commented Nov 6, 2017

I made a few small tweaks. Let's see if the bot likes it:

bors r+

bors bot added a commit that referenced this pull request Nov 6, 2017

Merge #466
466: Add documentation examples for parallel iterator methods r=cuviper a=mamuleanu

Closes #420
@lnicola

This comment has been minimized.

Copy link

lnicola commented Nov 6, 2017

@cuviper are you sure about the "Closes #420" part? I don't think this is complete.

@cuviper

This comment has been minimized.

Copy link
Member

cuviper commented Nov 6, 2017

Hmm, that's true, it's not quite complete. I think I'll just reopen after, instead of bothering bors about this.

@bors

This comment has been minimized.

Copy link
Contributor

bors bot commented Nov 7, 2017

@bors bors bot merged commit 2d3c873 into rayon-rs:master Nov 7, 2017

2 checks passed

bors Build succeeded
continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.