Skip to content

Commit 73545b7

Browse files
committed
fix(clippy): Make current version of Clippy happy.
1 parent eea3bdd commit 73545b7

File tree

8 files changed

+11
-10
lines changed

8 files changed

+11
-10
lines changed

src/arraytraits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ where
298298
{
299299
}
300300

301-
#[cfg(any(feature = "serde"))]
301+
#[cfg(feature = "serde")]
302302
// Use version number so we can add a packed format later.
303303
pub const ARRAY_FORMAT_VERSION: u8 = 1u8;
304304

src/dimension/dimension_trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub trait Dimension:
8383

8484
/// Compute the size of the dimension (number of elements)
8585
fn size(&self) -> usize {
86-
self.slice().iter().fold(1, |s, &a| s * a as usize)
86+
self.slice().iter().product()
8787
}
8888

8989
/// Compute the size while checking for overflow.
@@ -603,7 +603,7 @@ impl Dimension for Dim<[Ix; 2]> {
603603
fn size_checked(&self) -> Option<usize> {
604604
let m = get!(self, 0);
605605
let n = get!(self, 1);
606-
(m as usize).checked_mul(n as usize)
606+
m.checked_mul(n)
607607
}
608608

609609
#[inline]
@@ -728,7 +728,7 @@ impl Dimension for Dim<[Ix; 3]> {
728728
let m = get!(self, 0);
729729
let n = get!(self, 1);
730730
let o = get!(self, 2);
731-
m as usize * n as usize * o as usize
731+
m * n * o
732732
}
733733

734734
#[inline]

src/dimension/dynindeximpl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ impl<T: PartialEq> PartialEq for IxDynRepr<T> {
9696
match (self, rhs) {
9797
(&IxDynRepr::Inline(slen, ref sarr), &IxDynRepr::Inline(rlen, ref rarr)) => {
9898
slen == rlen
99-
&& (0..CAP as usize)
99+
&& (0..CAP)
100100
.filter(|&i| i < slen as usize)
101101
.all(|i| sarr[i] == rarr[i])
102102
}

src/dimension/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ mod sequence;
4747
/// Calculate offset from `Ix` stride converting sign properly
4848
#[inline(always)]
4949
pub fn stride_offset(n: Ix, stride: Ix) -> isize {
50-
(n as isize) * ((stride as Ixs) as isize)
50+
(n as isize) * (stride as Ixs)
5151
}
5252

5353
/// Check whether the given `dim` and `stride` lead to overlapping indices

src/impl_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1990,7 +1990,7 @@ where
19901990
let strides = unlimited_transmute::<D, D2>(self.strides);
19911991
return Ok(ArrayBase::from_data_ptr(self.data, self.ptr)
19921992
.with_strides_dim(strides, dim));
1993-
} else if D::NDIM == None || D2::NDIM == None { // one is dynamic dim
1993+
} else if D::NDIM.is_none() || D2::NDIM.is_none() { // one is dynamic dim
19941994
// safe because dim, strides are equivalent under a different type
19951995
if let Some(dim) = D2::from_dimension(&self.dim) {
19961996
if let Some(strides) = D2::from_dimension(&self.strides) {

src/indexes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
.slice()
7676
.iter()
7777
.zip(ix.slice().iter())
78-
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
78+
.fold(0, |s, (&a, &b)| s + a * b);
7979
self.dim.size() - gone
8080
}
8181
};
@@ -286,7 +286,7 @@ where
286286
.slice()
287287
.iter()
288288
.zip(self.index.slice().iter())
289-
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
289+
.fold(0, |s, (&a, &b)| s + a * b);
290290
let l = self.dim.size() - gone;
291291
(l, Some(l))
292292
}

src/iterators/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<A, D: Dimension> ExactSizeIterator for Baseiter<A, D> {
114114
.slice()
115115
.iter()
116116
.zip(ix.slice().iter())
117-
.fold(0, |s, (&a, &b)| s + a as usize * b as usize);
117+
.fold(0, |s, (&a, &b)| s + a * b);
118118
self.dim.size() - gone
119119
}
120120
}

src/zip/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ where
9292
{
9393
type Output = ArrayView<'a, A, E::Dim>;
9494
fn broadcast_unwrap(self, shape: E) -> Self::Output {
95+
#[allow(clippy::needless_borrow)]
9596
let res: ArrayView<'_, A, E::Dim> = (&self).broadcast_unwrap(shape.into_dimension());
9697
unsafe { ArrayView::new(res.ptr, res.dim, res.strides) }
9798
}

0 commit comments

Comments
 (0)