Skip to content

Commit 0e6b1d1

Browse files
VrixyzRalith
authored andcommitted
fix clippy complaints
1 parent 1c84b0c commit 0e6b1d1

20 files changed

+99
-86
lines changed

Cargo.toml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,14 @@ path = "src/lib.rs"
2323

2424
[features]
2525
default = ["std", "macros"]
26-
std = ["matrixmultiply", "num-traits/std", "num-complex/std", "num-rational/std", "approx/std", "simba/std"]
26+
std = [
27+
"matrixmultiply",
28+
"num-traits/std",
29+
"num-complex/std",
30+
"num-rational/std",
31+
"approx/std",
32+
"simba/std",
33+
]
2734
sparse = []
2835
debug = ["approx/num-complex", "rand"]
2936
alloc = []
@@ -67,7 +74,13 @@ rkyv-serialize = ["rkyv-serialize-no-std", "rkyv/std", "rkyv/validation"]
6774
## To use rand in a #[no-std] environment, enable the
6875
## `rand-no-std` feature instead of `rand`.
6976
rand-no-std = ["rand-package"]
70-
rand = ["rand-no-std", "rand-package/std", "rand-package/std_rng", "rand-package/thread_rng", "rand_distr"]
77+
rand = [
78+
"rand-no-std",
79+
"rand-package/std",
80+
"rand-package/std_rng",
81+
"rand-package/thread_rng",
82+
"rand_distr",
83+
]
7184

7285
# Tests
7386
arbitrary = ["quickcheck"]
@@ -87,15 +100,19 @@ simba = { version = "0.9", default-features = false }
87100
alga = { version = "0.9", default-features = false, optional = true }
88101
rand_distr = { version = "0.5", default-features = false, optional = true }
89102
matrixmultiply = { version = "0.3", optional = true }
90-
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
103+
serde = { version = "1.0", default-features = false, features = [
104+
"derive",
105+
], optional = true }
91106
rkyv = { version = "0.7.41", default-features = false, optional = true }
92107
mint = { version = "0.5", optional = true }
93108
quickcheck = { version = "1", optional = true }
94109
pest = { version = "2", optional = true }
95110
pest_derive = { version = "2", optional = true }
96111
bytemuck = { version = "1.5", optional = true }
97112
matrixcompare-core = { version = "0.1", optional = true }
98-
proptest = { version = "1", optional = true, default-features = false, features = ["std"] }
113+
proptest = { version = "1", optional = true, default-features = false, features = [
114+
"std",
115+
] }
99116
glam014 = { package = "glam", version = "0.14", optional = true }
100117
glam015 = { package = "glam", version = "0.15", optional = true }
101118
glam016 = { package = "glam", version = "0.16", optional = true }
@@ -131,7 +148,12 @@ trybuild = "1.0.90"
131148
cool_asserts = "2.0.3"
132149

133150
[workspace]
134-
members = ["nalgebra-lapack", "nalgebra-glm", "nalgebra-sparse", "nalgebra-macros"]
151+
members = [
152+
"nalgebra-lapack",
153+
"nalgebra-glm",
154+
"nalgebra-sparse",
155+
"nalgebra-macros",
156+
]
135157
resolver = "2"
136158

137159
[[example]]

nalgebra-sparse/src/factorization/cholesky.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ fn reach(
308308

309309
for &irow in pattern.lane(j) {
310310
let mut curr = irow;
311-
while curr != usize::max_value() && curr <= max_j && !marks[curr] {
311+
while curr != usize::MAX && curr <= max_j && !marks[curr] {
312312
marks[curr] = true;
313313
tmp.push(curr);
314314
curr = tree[curr];
@@ -352,8 +352,8 @@ fn elimination_tree(pattern: &SparsityPattern) -> Vec<usize> {
352352
// Note: The pattern is assumed to of a CSC matrix, so the number of rows is
353353
// given by the minor dimension
354354
let nrows = pattern.minor_dim();
355-
let mut forest: Vec<_> = iter::repeat(usize::max_value()).take(nrows).collect();
356-
let mut ancestor: Vec<_> = iter::repeat(usize::max_value()).take(nrows).collect();
355+
let mut forest: Vec<_> = iter::repeat(usize::MAX).take(nrows).collect();
356+
let mut ancestor: Vec<_> = iter::repeat(usize::MAX).take(nrows).collect();
357357

358358
for k in 0..nrows {
359359
for &irow in pattern.lane(k) {
@@ -363,7 +363,7 @@ fn elimination_tree(pattern: &SparsityPattern) -> Vec<usize> {
363363
let i_ancestor = ancestor[i];
364364
ancestor[i] = k;
365365

366-
if i_ancestor == usize::max_value() {
366+
if i_ancestor == usize::MAX {
367367
forest[i] = k;
368368
break;
369369
}

src/base/dimension.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl<'de> Deserialize<'de> for Dyn {
5353
where
5454
D: Deserializer<'de>,
5555
{
56-
usize::deserialize(deserializer).map(|x| Dyn(x))
56+
usize::deserialize(deserializer).map(Dyn)
5757
}
5858
}
5959

src/base/iter.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
//! Matrix iterators.
22
3-
// only enables the `doc_cfg` feature when
4-
// the `docsrs` configuration attribute is defined
5-
#![cfg_attr(docsrs, feature(doc_cfg))]
6-
73
use core::fmt::Debug;
84
use core::ops::Range;
95
use std::iter::FusedIterator;

src/base/matrix_view.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,13 @@ view_storage_impl!("A mutable matrix data storage for mutable matrix view. Only
131131
RawStorageMut as &'a mut S; SliceStorageMut => ViewStorageMut.get_address_unchecked_mut(*mut T as &'a mut T)
132132
);
133133

134-
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy
135-
for ViewStorage<'a, T, R, C, RStride, CStride>
134+
impl<T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Copy
135+
for ViewStorage<'_, T, R, C, RStride, CStride>
136136
{
137137
}
138138

139-
impl<'a, T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
140-
for ViewStorage<'a, T, R, C, RStride, CStride>
139+
impl<T: Scalar, R: Dim, C: Dim, RStride: Dim, CStride: Dim> Clone
140+
for ViewStorage<'_, T, R, C, RStride, CStride>
141141
{
142142
#[inline]
143143
fn clone(&self) -> Self {
@@ -240,8 +240,8 @@ macro_rules! storage_impl(
240240

241241
storage_impl!(ViewStorage, ViewStorageMut);
242242

243-
unsafe impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorageMut<T, R, C>
244-
for ViewStorageMut<'a, T, R, C, RStride, CStride>
243+
unsafe impl<T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorageMut<T, R, C>
244+
for ViewStorageMut<'_, T, R, C, RStride, CStride>
245245
{
246246
#[inline]
247247
fn ptr_mut(&mut self) -> *mut T {
@@ -260,18 +260,15 @@ unsafe impl<'a, T, R: Dim, C: Dim, RStride: Dim, CStride: Dim> RawStorageMut<T,
260260
}
261261
}
262262

263-
unsafe impl<'a, T, R: Dim, CStride: Dim> IsContiguous for ViewStorage<'a, T, R, U1, U1, CStride> {}
264-
unsafe impl<'a, T, R: Dim, CStride: Dim> IsContiguous
265-
for ViewStorageMut<'a, T, R, U1, U1, CStride>
266-
{
267-
}
263+
unsafe impl<T, R: Dim, CStride: Dim> IsContiguous for ViewStorage<'_, T, R, U1, U1, CStride> {}
264+
unsafe impl<T, R: Dim, CStride: Dim> IsContiguous for ViewStorageMut<'_, T, R, U1, U1, CStride> {}
268265

269-
unsafe impl<'a, T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
270-
for ViewStorage<'a, T, R, C, U1, R>
266+
unsafe impl<T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
267+
for ViewStorage<'_, T, R, C, U1, R>
271268
{
272269
}
273-
unsafe impl<'a, T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
274-
for ViewStorageMut<'a, T, R, C, U1, R>
270+
unsafe impl<T, R: DimName, C: Dim + IsNotStaticOne> IsContiguous
271+
for ViewStorageMut<'_, T, R, C, U1, R>
275272
{
276273
}
277274

src/base/ops.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ where
9595
}
9696
}
9797

98-
impl<'a, T, R: Dim, C: Dim, S> Neg for &'a Matrix<T, R, C, S>
98+
impl<T, R: Dim, C: Dim, S> Neg for &Matrix<T, R, C, S>
9999
where
100100
T: Scalar + ClosedNeg,
101101
S: Storage<T, R, C>,
@@ -550,8 +550,8 @@ macro_rules! left_scalar_mul_impl(
550550
left_scalar_mul_impl!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize, f32, f64);
551551

552552
// Matrix × Matrix
553-
impl<'a, 'b, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix<T, R2, C2, SB>>
554-
for &'a Matrix<T, R1, C1, SA>
553+
impl<'b, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<&'b Matrix<T, R2, C2, SB>>
554+
for &Matrix<T, R1, C1, SA>
555555
where
556556
T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign,
557557
SA: Storage<T, R1, C1>,
@@ -572,8 +572,8 @@ where
572572
}
573573
}
574574

575-
impl<'a, T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<Matrix<T, R2, C2, SB>>
576-
for &'a Matrix<T, R1, C1, SA>
575+
impl<T, R1: Dim, C1: Dim, R2: Dim, C2: Dim, SA, SB> Mul<Matrix<T, R2, C2, SB>>
576+
for &Matrix<T, R1, C1, SA>
577577
where
578578
T: Scalar + Zero + One + ClosedAddAssign + ClosedMulAssign,
579579
SB: Storage<T, R2, C2>,

src/base/par_iter.rs

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
//! Parallel iterators for matrices compatible with rayon.
22
3-
// only enables the `doc_cfg` feature when
4-
// the `docsrs` configuration attribute is defined
5-
#![cfg_attr(docsrs, feature(doc_cfg))]
6-
73
use crate::{
84
iter::{ColumnIter, ColumnIterMut},
95
Dim, Matrix, MatrixView, MatrixViewMut, RawStorage, RawStorageMut, Scalar, U1,
@@ -15,9 +11,10 @@ use rayon::{iter::plumbing::bridge, prelude::*};
1511
/// using the [`par_column_iter`] method of [`Matrix`].
1612
///
1713
/// *Only available if compiled with the feature `rayon`.*
14+
///
1815
/// [`par_column_iter`]: crate::Matrix::par_column_iter
1916
/// [`Matrix`]: crate::Matrix
20-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
17+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
2118
pub struct ParColumnIter<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> {
2219
mat: &'a Matrix<T, R, Cols, S>,
2320
}
@@ -29,7 +26,7 @@ impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> ParColumnIter<'a, T, R
2926
}
3027
}
3128

32-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
29+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
3330
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> ParallelIterator
3431
for ParColumnIter<'a, T, R, Cols, S>
3532
where
@@ -50,10 +47,10 @@ where
5047
}
5148
}
5249

53-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
50+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
5451
/// *Only available if compiled with the feature `rayon`.*
55-
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> IndexedParallelIterator
56-
for ParColumnIter<'a, T, R, Cols, S>
52+
impl<T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> IndexedParallelIterator
53+
for ParColumnIter<'_, T, R, Cols, S>
5754
where
5855
T: Send + Sync + Scalar,
5956
S: Sync,
@@ -75,7 +72,7 @@ where
7572
}
7673
}
7774

78-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
75+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
7976
/// A rayon parallel iterator through the mutable columns of a matrix.
8077
/// *Only available if compiled with the feature `rayon`.*
8178
pub struct ParColumnIterMut<
@@ -88,7 +85,7 @@ pub struct ParColumnIterMut<
8885
mat: &'a mut Matrix<T, R, Cols, S>,
8986
}
9087

91-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
88+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
9289
/// *only available if compiled with the feature `rayon`*
9390
impl<'a, T, R, Cols, S> ParColumnIterMut<'a, T, R, Cols, S>
9491
where
@@ -102,7 +99,7 @@ where
10299
}
103100
}
104101

105-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
102+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
106103
/// *Only available if compiled with the feature `rayon`*
107104
impl<'a, T, R, Cols, S> ParallelIterator for ParColumnIterMut<'a, T, R, Cols, S>
108105
where
@@ -125,9 +122,9 @@ where
125122
}
126123
}
127124

128-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
125+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
129126
/// *Only available if compiled with the feature `rayon`*
130-
impl<'a, T, R, Cols, S> IndexedParallelIterator for ParColumnIterMut<'a, T, R, Cols, S>
127+
impl<T, R, Cols, S> IndexedParallelIterator for ParColumnIterMut<'_, T, R, Cols, S>
131128
where
132129
R: Dim,
133130
Cols: Dim,
@@ -152,7 +149,7 @@ where
152149
}
153150
}
154151

155-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
152+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
156153
/// # Parallel iterators using `rayon`
157154
/// *Only available if compiled with the feature `rayon`*
158155
impl<T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Matrix<T, R, Cols, S>
@@ -225,7 +222,7 @@ where
225222
/// rayon trait part of the public interface of the `ColumnIter`.
226223
struct ColumnProducer<'a, T, R: Dim, C: Dim, S: RawStorage<T, R, C>>(ColumnIter<'a, T, R, C, S>);
227224

228-
#[cfg_attr(doc_cfg, doc(cfg(feature = "rayon")))]
225+
#[cfg_attr(docsrs, doc(cfg(feature = "rayon")))]
229226
/// *only available if compiled with the feature `rayon`*
230227
impl<'a, T, R: Dim, Cols: Dim, S: RawStorage<T, R, Cols>> Producer
231228
for ColumnProducer<'a, T, R, Cols, S>

src/base/rkyv_wrappers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Wrapper that allows changing the generic type of a PhantomData<T>
1+
//! Wrapper that allows changing the generic type of a `PhantomData<NT>`
22
//!
33
//! Copied from <https://github.com/rkyv/rkyv_contrib> (MIT-Apache2 licences) which isn’t published yet.
44
@@ -8,7 +8,7 @@ use rkyv::{
88
};
99
use std::marker::PhantomData;
1010

11-
/// A wrapper that allows for changing the generic type of a `PhantomData<T>`.
11+
/// A wrapper that allows for changing the generic type of a `PhantomData<NT>`.
1212
pub struct CustomPhantom<NT: ?Sized> {
1313
_data: PhantomData<*const NT>,
1414
}

src/debug/random_sdp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ where
3232
/// Creates a new well conditioned symmetric definite-positive matrix from its dimension and a
3333
/// random reals generators.
3434
pub fn new<Rand: FnMut() -> T>(dim: D, mut rand: Rand) -> Self {
35-
let mut m = RandomOrthogonal::new(dim, || rand()).unwrap();
35+
let mut m = RandomOrthogonal::new(dim, &mut rand).unwrap();
3636
let mt = m.adjoint();
3737

3838
for i in 0..dim.value() {

src/geometry/dual_quaternion_ops.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898
}
9999
}
100100

101-
impl<'a, T: SimdRealField> Neg for &'a DualQuaternion<T>
101+
impl<T: SimdRealField> Neg for &DualQuaternion<T>
102102
where
103103
T::Element: SimdRealField,
104104
{
@@ -122,7 +122,7 @@ where
122122
}
123123
}
124124

125-
impl<'a, T: SimdRealField> Neg for &'a UnitDualQuaternion<T>
125+
impl<T: SimdRealField> Neg for &UnitDualQuaternion<T>
126126
where
127127
T::Element: SimdRealField,
128128
{

src/geometry/point_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ where
6262
}
6363
}
6464

65-
impl<'a, T: Scalar + ClosedNeg, D: DimName> Neg for &'a OPoint<T, D>
65+
impl<T: Scalar + ClosedNeg, D: DimName> Neg for &OPoint<T, D>
6666
where
6767
DefaultAllocator: Allocator<D>,
6868
{

src/geometry/quaternion_construction.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ impl<T> Quaternion<T> {
5959
/// let q2 = q.cast::<f32>();
6060
/// assert_eq!(q2, Quaternion::new(1.0f32, 2.0, 3.0, 4.0));
6161
/// ```
62-
pub fn cast<To: Scalar>(self) -> Quaternion<To>
62+
pub fn cast<To>(self) -> Quaternion<To>
6363
where
6464
T: Scalar,
65-
To: SupersetOf<T>,
65+
To: Scalar + SupersetOf<T>,
6666
{
6767
crate::convert(self)
6868
}
@@ -231,9 +231,9 @@ where
231231
/// let q2 = q.cast::<f32>();
232232
/// assert_relative_eq!(q2, UnitQuaternion::from_euler_angles(1.0f32, 2.0, 3.0), epsilon = 1.0e-6);
233233
/// ```
234-
pub fn cast<To: Scalar>(self) -> UnitQuaternion<To>
234+
pub fn cast<To>(self) -> UnitQuaternion<To>
235235
where
236-
To: SupersetOf<T>,
236+
To: Scalar + SupersetOf<T>,
237237
{
238238
crate::convert(self)
239239
}

src/geometry/quaternion_ops.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ where
549549
}
550550
}
551551

552-
impl<'a, T: SimdRealField> Neg for &'a Quaternion<T>
552+
impl<T: SimdRealField> Neg for &Quaternion<T>
553553
where
554554
T::Element: SimdRealField,
555555
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy