Skip to content

Commit 9c703ac

Browse files
committed
Fixing lifetime elisions and minor clippy complaints
1 parent fd3ce5d commit 9c703ac

File tree

17 files changed

+60
-61
lines changed

17 files changed

+60
-61
lines changed

crates/ndarray-gen/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@
88
// except according to those terms.
99

1010
/// Build ndarray arrays for test purposes
11-
1211
pub mod array_builder;

examples/bounds_check_elim.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub fn test1d_single_mut(a: &mut Array1<f64>, i: usize) -> f64
5757
#[no_mangle]
5858
pub fn test1d_len_of(a: &Array1<f64>) -> f64
5959
{
60-
let a = &*a;
60+
let a = a;
6161
let mut sum = 0.;
6262
for i in 0..a.len_of(Axis(0)) {
6363
sum += a[i];

ndarray-rand/tests/tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ fn sampling_works(a: &Array2<f64>, strategy: SamplingStrategy, axis: Axis, n_sam
122122
let samples = a.sample_axis(axis, n_samples, strategy);
123123
samples
124124
.axis_iter(axis)
125-
.all(|lane| is_subset(&a, &lane, axis))
125+
.all(|lane| is_subset(a, &lane, axis))
126126
}
127127

128128
// Check if, when sliced along `axis`, there is at least one lane in `a` equal to `b`

src/argument_traits.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait AssignElem<T>
1111
}
1212

1313
/// Assignable element, simply `*self = input`.
14-
impl<'a, T> AssignElem<T> for &'a mut T
14+
impl<T> AssignElem<T> for &mut T
1515
{
1616
fn assign_elem(self, input: T)
1717
{
@@ -20,7 +20,7 @@ impl<'a, T> AssignElem<T> for &'a mut T
2020
}
2121

2222
/// Assignable element, simply `self.set(input)`.
23-
impl<'a, T> AssignElem<T> for &'a Cell<T>
23+
impl<T> AssignElem<T> for &Cell<T>
2424
{
2525
fn assign_elem(self, input: T)
2626
{
@@ -29,7 +29,7 @@ impl<'a, T> AssignElem<T> for &'a Cell<T>
2929
}
3030

3131
/// Assignable element, simply `self.set(input)`.
32-
impl<'a, T> AssignElem<T> for &'a MathCell<T>
32+
impl<T> AssignElem<T> for &MathCell<T>
3333
{
3434
fn assign_elem(self, input: T)
3535
{
@@ -39,7 +39,7 @@ impl<'a, T> AssignElem<T> for &'a MathCell<T>
3939

4040
/// Assignable element, the item in the MaybeUninit is overwritten (prior value, if any, is not
4141
/// read or dropped).
42-
impl<'a, T> AssignElem<T> for &'a mut MaybeUninit<T>
42+
impl<T> AssignElem<T> for &mut MaybeUninit<T>
4343
{
4444
fn assign_elem(self, input: T)
4545
{

src/array_serde.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ where
9898
// private iterator wrapper
9999
struct Sequence<'a, A, D>(Iter<'a, A, D>);
100100

101-
impl<'a, A, D> Serialize for Sequence<'a, A, D>
101+
impl<A, D> Serialize for Sequence<'_, A, D>
102102
where
103103
A: Serialize,
104104
D: Dimension + Serialize,
@@ -162,7 +162,7 @@ impl<'de> Deserialize<'de> for ArrayField
162162
{
163163
struct ArrayFieldVisitor;
164164

165-
impl<'de> Visitor<'de> for ArrayFieldVisitor
165+
impl Visitor<'_> for ArrayFieldVisitor
166166
{
167167
type Value = ArrayField;
168168

src/arraytraits.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ where
128128
/// Return `true` if the array shapes and all elements of `self` and
129129
/// `rhs` are equal. Return `false` otherwise.
130130
#[allow(clippy::unconditional_recursion)] // false positive
131-
impl<'a, A, B, S, S2, D> PartialEq<&'a ArrayBase<S2, D>> for ArrayBase<S, D>
131+
impl<A, B, S, S2, D> PartialEq<&ArrayBase<S2, D>> for ArrayBase<S, D>
132132
where
133133
A: PartialEq<B>,
134134
S: Data<Elem = A>,
@@ -144,7 +144,7 @@ where
144144
/// Return `true` if the array shapes and all elements of `self` and
145145
/// `rhs` are equal. Return `false` otherwise.
146146
#[allow(clippy::unconditional_recursion)] // false positive
147-
impl<'a, A, B, S, S2, D> PartialEq<ArrayBase<S2, D>> for &'a ArrayBase<S, D>
147+
impl<A, B, S, S2, D> PartialEq<ArrayBase<S2, D>> for &ArrayBase<S, D>
148148
where
149149
A: PartialEq<B>,
150150
S: Data<Elem = A>,

src/data_traits.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ where A: Clone
407407
}
408408
}
409409

410-
unsafe impl<'a, A> RawData for ViewRepr<&'a A>
410+
unsafe impl<A> RawData for ViewRepr<&A>
411411
{
412412
type Elem = A;
413413

@@ -420,7 +420,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a A>
420420
private_impl! {}
421421
}
422422

423-
unsafe impl<'a, A> Data for ViewRepr<&'a A>
423+
unsafe impl<A> Data for ViewRepr<&A>
424424
{
425425
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
426426
where
@@ -437,15 +437,15 @@ unsafe impl<'a, A> Data for ViewRepr<&'a A>
437437
}
438438
}
439439

440-
unsafe impl<'a, A> RawDataClone for ViewRepr<&'a A>
440+
unsafe impl<A> RawDataClone for ViewRepr<&A>
441441
{
442442
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
443443
{
444444
(*self, ptr)
445445
}
446446
}
447447

448-
unsafe impl<'a, A> RawData for ViewRepr<&'a mut A>
448+
unsafe impl<A> RawData for ViewRepr<&mut A>
449449
{
450450
type Elem = A;
451451

@@ -458,7 +458,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a mut A>
458458
private_impl! {}
459459
}
460460

461-
unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A>
461+
unsafe impl<A> RawDataMut for ViewRepr<&mut A>
462462
{
463463
#[inline]
464464
fn try_ensure_unique<D>(_: &mut ArrayBase<Self, D>)
@@ -475,7 +475,7 @@ unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A>
475475
}
476476
}
477477

478-
unsafe impl<'a, A> Data for ViewRepr<&'a mut A>
478+
unsafe impl<A> Data for ViewRepr<&mut A>
479479
{
480480
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
481481
where
@@ -492,7 +492,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a mut A>
492492
}
493493
}
494494

495-
unsafe impl<'a, A> DataMut for ViewRepr<&'a mut A> {}
495+
unsafe impl<A> DataMut for ViewRepr<&mut A> {}
496496

497497
/// Array representation trait.
498498
///
@@ -533,7 +533,7 @@ pub unsafe trait DataOwned: Data
533533
pub unsafe trait DataShared: Clone + Data + RawDataClone {}
534534

535535
unsafe impl<A> DataShared for OwnedArcRepr<A> {}
536-
unsafe impl<'a, A> DataShared for ViewRepr<&'a A> {}
536+
unsafe impl<A> DataShared for ViewRepr<&A> {}
537537

538538
unsafe impl<A> DataOwned for OwnedRepr<A>
539539
{
@@ -571,7 +571,7 @@ unsafe impl<A> DataOwned for OwnedArcRepr<A>
571571
}
572572
}
573573

574-
unsafe impl<'a, A> RawData for CowRepr<'a, A>
574+
unsafe impl<A> RawData for CowRepr<'_, A>
575575
{
576576
type Elem = A;
577577

@@ -587,7 +587,7 @@ unsafe impl<'a, A> RawData for CowRepr<'a, A>
587587
private_impl! {}
588588
}
589589

590-
unsafe impl<'a, A> RawDataMut for CowRepr<'a, A>
590+
unsafe impl<A> RawDataMut for CowRepr<'_, A>
591591
where A: Clone
592592
{
593593
#[inline]
@@ -615,7 +615,7 @@ where A: Clone
615615
}
616616
}
617617

618-
unsafe impl<'a, A> RawDataClone for CowRepr<'a, A>
618+
unsafe impl<A> RawDataClone for CowRepr<'_, A>
619619
where A: Clone
620620
{
621621
unsafe fn clone_with_ptr(&self, ptr: NonNull<Self::Elem>) -> (Self, NonNull<Self::Elem>)
@@ -681,7 +681,7 @@ unsafe impl<'a, A> Data for CowRepr<'a, A>
681681
}
682682
}
683683

684-
unsafe impl<'a, A> DataMut for CowRepr<'a, A> where A: Clone {}
684+
unsafe impl<A> DataMut for CowRepr<'_, A> where A: Clone {}
685685

686686
unsafe impl<'a, A> DataOwned for CowRepr<'a, A>
687687
{

src/dimension/axes.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ pub struct AxisDescription
6060
copy_and_clone!(AxisDescription);
6161
copy_and_clone!(['a, D] Axes<'a, D>);
6262

63-
impl<'a, D> Iterator for Axes<'a, D>
63+
impl<D> Iterator for Axes<'_, D>
6464
where D: Dimension
6565
{
6666
/// Description of the axis, its length and its stride.
@@ -99,7 +99,7 @@ where D: Dimension
9999
}
100100
}
101101

102-
impl<'a, D> DoubleEndedIterator for Axes<'a, D>
102+
impl<D> DoubleEndedIterator for Axes<'_, D>
103103
where D: Dimension
104104
{
105105
fn next_back(&mut self) -> Option<Self::Item>

src/dimension/ndindex.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ unsafe impl<const N: usize> NdIndex<IxDyn> for [Ix; N]
255255
}
256256
}
257257

258-
impl<'a> IntoDimension for &'a [Ix]
258+
impl IntoDimension for &[Ix]
259259
{
260260
type Dim = IxDyn;
261261
fn into_dimension(self) -> Self::Dim
@@ -264,7 +264,7 @@ impl<'a> IntoDimension for &'a [Ix]
264264
}
265265
}
266266

267-
unsafe impl<'a> NdIndex<IxDyn> for &'a IxDyn
267+
unsafe impl NdIndex<IxDyn> for &IxDyn
268268
{
269269
fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize>
270270
{
@@ -276,7 +276,7 @@ unsafe impl<'a> NdIndex<IxDyn> for &'a IxDyn
276276
}
277277
}
278278

279-
unsafe impl<'a> NdIndex<IxDyn> for &'a [Ix]
279+
unsafe impl NdIndex<IxDyn> for &[Ix]
280280
{
281281
fn index_checked(&self, dim: &IxDyn, strides: &IxDyn) -> Option<isize>
282282
{

src/impl_cow.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::imp_prelude::*;
1111
/// Methods specific to `CowArray`.
1212
///
1313
/// ***See also all methods for [`ArrayBase`]***
14-
impl<'a, A, D> CowArray<'a, A, D>
14+
impl<A, D> CowArray<'_, A, D>
1515
where D: Dimension
1616
{
1717
/// Returns `true` iff the array is the view (borrowed) variant.

src/impl_views/constructors.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ where D: Dimension
230230
}
231231

232232
/// Private array view methods
233-
impl<'a, A, D> ArrayView<'a, A, D>
233+
impl<A, D> ArrayView<'_, A, D>
234234
where D: Dimension
235235
{
236236
/// Create a new `ArrayView`
@@ -254,7 +254,7 @@ where D: Dimension
254254
}
255255
}
256256

257-
impl<'a, A, D> ArrayViewMut<'a, A, D>
257+
impl<A, D> ArrayViewMut<'_, A, D>
258258
where D: Dimension
259259
{
260260
/// Create a new `ArrayView`

src/impl_views/indexing.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub trait IndexLonger<I>
100100
unsafe fn uget(self, index: I) -> Self::Output;
101101
}
102102

103-
impl<'a, 'b, I, A, D> IndexLonger<I> for &'b ArrayView<'a, A, D>
103+
impl<'a, I, A, D> IndexLonger<I> for &ArrayView<'a, A, D>
104104
where
105105
I: NdIndex<D>,
106106
D: Dimension,

src/impl_views/splitting.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::slice::MultiSliceArg;
1111
use num_complex::Complex;
1212

1313
/// Methods for read-only array views.
14-
impl<'a, A, D> ArrayView<'a, A, D>
14+
impl<A, D> ArrayView<'_, A, D>
1515
where D: Dimension
1616
{
1717
/// Split the array view along `axis` and return one view strictly before the

0 commit comments

Comments
 (0)