Skip to content

Commit ec4d972

Browse files
committed
FIX: In Zip, move dimension check to free function
This reduces the generic parameters the function depends on, so that it is instantiated less often.
1 parent 8bce8cc commit ec4d972

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/zip/mod.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,25 @@ where
240240
}
241241
}
242242

243-
impl<Parts, D> Zip<Parts, D>
243+
#[inline]
244+
fn zip_dimension_check<D, P>(dimension: &D, part: &P)
244245
where
245246
D: Dimension,
247+
P: NdProducer<Dim = D>,
246248
{
247-
fn check<P>(&self, part: &P)
248-
where
249-
P: NdProducer<Dim = D>,
250-
{
251-
ndassert!(
252-
part.equal_dim(&self.dimension),
253-
"Zip: Producer dimension mismatch, expected: {:?}, got: {:?}",
254-
self.dimension,
255-
part.raw_dim()
256-
);
257-
}
249+
ndassert!(
250+
part.equal_dim(&dimension),
251+
"Zip: Producer dimension mismatch, expected: {:?}, got: {:?}",
252+
dimension,
253+
part.raw_dim()
254+
);
255+
}
256+
258257

258+
impl<Parts, D> Zip<Parts, D>
259+
where
260+
D: Dimension,
261+
{
259262
/// Return a the number of element tuples in the Zip
260263
pub fn size(&self) -> usize {
261264
self.dimension.size()
@@ -652,7 +655,7 @@ macro_rules! map_impl {
652655
where P: IntoNdProducer<Dim=D>,
653656
{
654657
let part = p.into_producer();
655-
self.check(&part);
658+
zip_dimension_check(&self.dimension, &part);
656659
self.build_and(part)
657660
}
658661

0 commit comments

Comments
 (0)