Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd Update adaptor and `update()` method #488
Conversation
cuviper
requested changes
Dec 8, 2017
|
This looks great, thanks! I do want a few more tests just for uniformity, adding this to |
| /// ``` | ||
| /// use rayon::prelude::*; | ||
| /// | ||
| /// let mut par_iter = (0..5).into_par_iter().update(|mut x| {*x *= 2;}); |
This comment has been minimized.
This comment has been minimized.
cuviper
Dec 8, 2017
Member
nit: I don't think you need either mut here. par_iter will be moved into collect(), and x is already &mut.
| } | ||
| } | ||
|
|
||
| /// Standard Update adaptor, based on `itertools::adaptors::Update` |
This comment has been minimized.
This comment has been minimized.
cuviper
Dec 8, 2017
Member
Did you consider using itertools directly? We wouldn't want a public dependency, but this is behind the scenes. But the implementation is pretty straightforward, so I'm just wondering what you think.
This comment has been minimized.
This comment has been minimized.
Enet4
Dec 8, 2017
Author
Contributor
I did think about that while reading the issue. I chose to replicate the implementation because interleave did the same, although with additional reasons.
If there is willingness to depend on itertools in future versions, I suppose this adaptor would take advantage of that. Although it's just my opinion, leaving these adaptors behind a feature gate to keep itertools an optional dependency feels a bit unnecessary.
cuviper
reviewed
Dec 8, 2017
| /// | ||
| /// assert_eq!(&doubles[..], &[0, 2, 4, 6, 8]); | ||
| /// ``` | ||
| fn update<F>(self, update_op: F) -> Update<Self, F> |
This comment has been minimized.
This comment has been minimized.
cuviper
Dec 8, 2017
Member
Also, just to keep related behavior grouped together, let's move this up after inspect.
Enet4
force-pushed the
Enet4:update_adaptor
branch
from
40ef3a8
to
0031f91
Dec 8, 2017
This comment has been minimized.
This comment has been minimized.
|
The requested adjustments were made. Please let me know if you'd like a commit squash. As for the actual use of |
cuviper
approved these changes
Dec 8, 2017
This comment has been minimized.
This comment has been minimized.
|
Thanks! We don't need to worry much about itertools -- we can always change this later if wanted. bors r+ |
Enet4 commentedDec 8, 2017
•
edited
This resolves #487. The sequential version created by the producer is based on the
itertoolsimplementation. Tests are included, but let me know if you'd like better coverage.