Skip to content

Commit 8bf18d7

Browse files
tweak ParallelBridge and IterBridge
1 parent 3d54ea2 commit 8bf18d7

File tree

2 files changed

+9
-18
lines changed

2 files changed

+9
-18
lines changed

src/iter/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ use self::plumbing::*;
8585
// can be readily distinguished.
8686

8787
mod par_bridge;
88-
pub use self::par_bridge::{ParallelBridge, IterParallel};
88+
pub use self::par_bridge::{ParallelBridge, IterBridge};
8989

9090
mod find;
9191
mod find_first_last;

src/iter/par_bridge.rs

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,42 +43,33 @@ use current_num_threads;
4343
///
4444
/// assert_eq!(&*output, &["one!", "three!", "two!"]);
4545
/// ```
46-
pub trait ParallelBridge {
47-
/// What is the type of the output `ParallelIterator`?
48-
type Iter: ParallelIterator<Item = Self::Item>;
49-
50-
/// What is the `Item` of the output `ParallelIterator`?
51-
type Item: Send;
52-
53-
/// Convert this type to a `ParallelIterator`.
54-
fn par_bridge(self) -> Self::Iter;
46+
pub trait ParallelBridge: Sized {
47+
/// Create a bridge from this type to a `ParallelIterator`.
48+
fn par_bridge(self) -> IterBridge<Self>;
5549
}
5650

5751
impl<T: Iterator + Send> ParallelBridge for T
5852
where T::Item: Send
5953
{
60-
type Iter = IterParallel<T>;
61-
type Item = T::Item;
62-
63-
fn par_bridge(self) -> Self::Iter {
64-
IterParallel {
54+
fn par_bridge(self) -> IterBridge<Self> {
55+
IterBridge {
6556
iter: self,
6657
}
6758
}
6859
}
6960

70-
/// `IterParallel` is a parallel iterator that wraps a sequential iterator.
61+
/// `IterBridge` is a parallel iterator that wraps a sequential iterator.
7162
///
7263
/// This type is created when using the `par_bridge` method on `ParallelBridge`. See the
7364
/// [`ParallelBridge`] documentation for details.
7465
///
7566
/// [`ParallelBridge`]: trait.ParallelBridge.html
7667
#[derive(Debug)]
77-
pub struct IterParallel<Iter> {
68+
pub struct IterBridge<Iter> {
7869
iter: Iter,
7970
}
8071

81-
impl<Iter: Iterator + Send> ParallelIterator for IterParallel<Iter>
72+
impl<Iter: Iterator + Send> ParallelIterator for IterBridge<Iter>
8273
where Iter::Item: Send
8374
{
8475
type Item = Iter::Item;

0 commit comments

Comments
 (0)