/// `MapWith` is an iterator that transforms the elements of an underlying iterator. /// /// This struct is created by the [`map_with()`] method on [`ParallelIterator`] /// /// [`map_with()`]: trait.ParallelIterator.html#method.map_with /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone)] pubstruct MapWith<I: ParallelIterator, T, F> {
base: I,
item: T,
map_op: F,
}
struct Callback<CB, U, F> {
callback: CB,
item: U,
map_op: F,
}
impl<T, U, F, R, CB> ProducerCallback<T> for Callback<CB, U, F> where
CB: ProducerCallback<R>,
U: Send + Clone,
F: Fn(&mut U, T) -> R + Sync,
R: Send,
{ type Output = CB::Output;
struct MapWithProducer<'f, P, U, F> {
base: P,
item: U,
map_op: &'f F,
}
impl<'f, P, U, F, R> Producer for MapWithProducer<'f, P, U, F> where
P: Producer,
U: Send + Clone,
F: Fn(&mut U, P::Item) -> R + Sync,
R: Send,
{ type Item = R; type IntoIter = MapWithIter<'f, P::IntoIter, U, F>;
impl<'f, I, U, F, R> DoubleEndedIterator for MapWithIter<'f, I, U, F> where
I: DoubleEndedIterator,
F: Fn(&mut U, I::Item) -> R + Sync,
R: Send,
{ fn next_back(&mutself) -> Option<R> { let item = self.base.next_back()?;
Some((self.map_op)(&mutself.item, item))
}
}
impl<'f, I, U, F, R> ExactSizeIterator for MapWithIter<'f, I, U, F> where
I: ExactSizeIterator,
F: Fn(&mut U, I::Item) -> R + Sync,
R: Send,
{
}
struct MapWithConsumer<'f, C, U, F> {
base: C,
item: U,
map_op: &'f F,
}
impl<'f, C, U, F> MapWithConsumer<'f, C, U, F> { fn new(base: C, item: U, map_op: &'f F) -> Self {
MapWithConsumer { base, item, map_op }
}
}
impl<'f, T, U, R, C, F> Consumer<T> for MapWithConsumer<'f, C, U, F> where
C: Consumer<R>,
U: Send + Clone,
F: Fn(&mut U, T) -> R + Sync,
R: Send,
{ type Folder = MapWithFolder<'f, C::Folder, U, F>; type Reducer = C::Reducer; type Result = C::Result;
/// `MapInit` is an iterator that transforms the elements of an underlying iterator. /// /// This struct is created by the [`map_init()`] method on [`ParallelIterator`] /// /// [`map_init()`]: trait.ParallelIterator.html#method.map_init /// [`ParallelIterator`]: trait.ParallelIterator.html #[must_use = "iterator adaptors are lazy and do nothing unless consumed"] #[derive(Clone)] pubstruct MapInit<I: ParallelIterator, INIT, F> {
base: I,
init: INIT,
map_op: F,
}
impl<T, INIT, U, F, R, CB> ProducerCallback<T> for Callback<CB, INIT, F> where
CB: ProducerCallback<R>,
INIT: Fn() -> U + Sync,
F: Fn(&mut U, T) -> R + Sync,
R: Send,
{ type Output = CB::Output;
impl<'f, P, INIT, U, F, R> Producer for MapInitProducer<'f, P, INIT, F> where
P: Producer,
INIT: Fn() -> U + Sync,
F: Fn(&mut U, P::Item) -> R + Sync,
R: Send,
{ type Item = R; type IntoIter = MapWithIter<'f, P::IntoIter, U, F>;
impl<'f, T, INIT, U, R, C, F> Consumer<T> for MapInitConsumer<'f, C, INIT, F> where
C: Consumer<R>,
INIT: Fn() -> U + Sync,
F: Fn(&mut U, T) -> R + Sync,
R: Send,
{ type Folder = MapWithFolder<'f, C::Folder, U, F>; type Reducer = C::Reducer; type Result = C::Result;
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.12Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-06-18)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.