Skip to content

Commit daaf625

Browse files
jturner314bluss
authored andcommitted
Use type aliases to simplify type signatures
Clippy warned that some of the types were too complex, so this commit simplifies those lines and a few others.
1 parent 36aa2be commit daaf625

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/data_traits.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ use std::ptr::NonNull;
1616
use alloc::sync::Arc;
1717
use alloc::vec::Vec;
1818

19-
use crate::{ArrayBase, CowRepr, Dimension, OwnedArcRepr, OwnedRepr, RawViewRepr, ViewRepr};
19+
use crate::{
20+
ArcArray, Array, ArrayBase, CowRepr, Dimension, OwnedArcRepr, OwnedRepr, RawViewRepr, ViewRepr,
21+
};
2022

2123
/// Array representation trait.
2224
///
@@ -104,7 +106,7 @@ pub unsafe trait Data: RawData {
104106
/// Converts the array to a uniquely owned array, cloning elements if necessary.
105107
#[doc(hidden)]
106108
#[allow(clippy::wrong_self_convention)]
107-
fn into_owned<D>(self_: ArrayBase<Self, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
109+
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
108110
where
109111
Self::Elem: Clone,
110112
D: Dimension;
@@ -114,15 +116,15 @@ pub unsafe trait Data: RawData {
114116
#[doc(hidden)]
115117
fn try_into_owned_nocopy<D>(
116118
self_: ArrayBase<Self, D>,
117-
) -> Result<ArrayBase<OwnedRepr<Self::Elem>, D>, ArrayBase<Self, D>>
119+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
118120
where
119121
D: Dimension;
120122

121123
/// Return a shared ownership (copy on write) array based on the existing one,
122124
/// cloning elements if necessary.
123125
#[doc(hidden)]
124126
#[allow(clippy::wrong_self_convention)]
125-
fn to_shared<D>(self_: &ArrayBase<Self, D>) -> ArrayBase<OwnedArcRepr<Self::Elem>, D>
127+
fn to_shared<D>(self_: &ArrayBase<Self, D>) -> ArcArray<Self::Elem, D>
126128
where
127129
Self::Elem: Clone,
128130
D: Dimension,
@@ -271,7 +273,7 @@ where
271273
}
272274

273275
unsafe impl<A> Data for OwnedArcRepr<A> {
274-
fn into_owned<D>(mut self_: ArrayBase<Self, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
276+
fn into_owned<D>(mut self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
275277
where
276278
A: Clone,
277279
D: Dimension,
@@ -287,7 +289,7 @@ unsafe impl<A> Data for OwnedArcRepr<A> {
287289

288290
fn try_into_owned_nocopy<D>(
289291
self_: ArrayBase<Self, D>,
290-
) -> Result<ArrayBase<OwnedRepr<Self::Elem>, D>, ArrayBase<Self, D>>
292+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
291293
where
292294
D: Dimension,
293295
{
@@ -307,7 +309,7 @@ unsafe impl<A> Data for OwnedArcRepr<A> {
307309
}
308310

309311
#[allow(clippy::wrong_self_convention)]
310-
fn to_shared<D>(self_: &ArrayBase<Self, D>) -> ArrayBase<OwnedArcRepr<Self::Elem>, D>
312+
fn to_shared<D>(self_: &ArrayBase<Self, D>) -> ArcArray<Self::Elem, D>
311313
where
312314
Self::Elem: Clone,
313315
D: Dimension,
@@ -360,7 +362,7 @@ unsafe impl<A> RawDataMut for OwnedRepr<A> {
360362

361363
unsafe impl<A> Data for OwnedRepr<A> {
362364
#[inline]
363-
fn into_owned<D>(self_: ArrayBase<Self, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
365+
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
364366
where
365367
A: Clone,
366368
D: Dimension,
@@ -371,7 +373,7 @@ unsafe impl<A> Data for OwnedRepr<A> {
371373
#[inline]
372374
fn try_into_owned_nocopy<D>(
373375
self_: ArrayBase<Self, D>,
374-
) -> Result<ArrayBase<Self, D>, ArrayBase<Self, D>>
376+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
375377
where
376378
D: Dimension,
377379
{
@@ -426,7 +428,7 @@ unsafe impl<'a, A> RawData for ViewRepr<&'a A> {
426428
}
427429

428430
unsafe impl<'a, A> Data for ViewRepr<&'a A> {
429-
fn into_owned<D>(self_: ArrayBase<Self, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
431+
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
430432
where
431433
Self::Elem: Clone,
432434
D: Dimension,
@@ -436,7 +438,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a A> {
436438

437439
fn try_into_owned_nocopy<D>(
438440
self_: ArrayBase<Self, D>,
439-
) -> Result<ArrayBase<OwnedRepr<Self::Elem>, D>, ArrayBase<Self, D>>
441+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
440442
where
441443
D: Dimension,
442444
{
@@ -480,7 +482,7 @@ unsafe impl<'a, A> RawDataMut for ViewRepr<&'a mut A> {
480482
}
481483

482484
unsafe impl<'a, A> Data for ViewRepr<&'a mut A> {
483-
fn into_owned<D>(self_: ArrayBase<Self, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
485+
fn into_owned<D>(self_: ArrayBase<Self, D>) -> Array<Self::Elem, D>
484486
where
485487
Self::Elem: Clone,
486488
D: Dimension,
@@ -490,7 +492,7 @@ unsafe impl<'a, A> Data for ViewRepr<&'a mut A> {
490492

491493
fn try_into_owned_nocopy<D>(
492494
self_: ArrayBase<Self, D>,
493-
) -> Result<ArrayBase<OwnedRepr<Self::Elem>, D>, ArrayBase<Self, D>>
495+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
494496
where
495497
D: Dimension,
496498
{
@@ -653,7 +655,7 @@ where
653655

654656
unsafe impl<'a, A> Data for CowRepr<'a, A> {
655657
#[inline]
656-
fn into_owned<D>(self_: ArrayBase<CowRepr<'a, A>, D>) -> ArrayBase<OwnedRepr<Self::Elem>, D>
658+
fn into_owned<D>(self_: ArrayBase<CowRepr<'a, A>, D>) -> Array<Self::Elem, D>
657659
where
658660
A: Clone,
659661
D: Dimension,
@@ -670,7 +672,7 @@ unsafe impl<'a, A> Data for CowRepr<'a, A> {
670672

671673
fn try_into_owned_nocopy<D>(
672674
self_: ArrayBase<Self, D>,
673-
) -> Result<ArrayBase<OwnedRepr<Self::Elem>, D>, ArrayBase<Self, D>>
675+
) -> Result<Array<Self::Elem, D>, ArrayBase<Self, D>>
674676
where
675677
D: Dimension,
676678
{

0 commit comments

Comments
 (0)