Skip to content

Commit ac583c5

Browse files
committed
Remove the helper traits (for now) to make the diff smaller
1 parent 3380d94 commit ac583c5

File tree

5 files changed

+9
-40
lines changed

5 files changed

+9
-40
lines changed

examples/functions_and_traits.rs

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,7 @@
1111
//!
1212
//! Below, we illustrate how to write functions and traits for most variants of these types.
1313
14-
use ndarray::{
15-
ArrayBase,
16-
ArrayRef,
17-
AsLayoutRef,
18-
AsMutLayoutRef,
19-
AsMutRawRef,
20-
AsRawRef,
21-
Data,
22-
DataMut,
23-
Dimension,
24-
LayoutRef,
25-
RawData,
26-
RawDataMut,
27-
RawRef,
28-
};
14+
use ndarray::{ArrayBase, ArrayRef, Data, DataMut, Dimension, LayoutRef, RawData, RawDataMut, RawRef};
2915

3016
/// Take an array with the most basic requirements.
3117
///
@@ -153,19 +139,19 @@ fn takes_rawref_mut<A, D>(arr: &mut RawRef<A, D>)
153139
/// Immutable, take a generic that implements `AsRef` to `RawRef`
154140
#[allow(dead_code)]
155141
fn takes_rawref_asref<T, A, D>(_arr: &T)
156-
where T: AsRawRef<A, D> + ?Sized
142+
where T: AsRef<RawRef<A, D>> + ?Sized
157143
{
158144
takes_layout(_arr.as_ref());
159-
takes_layout_asref(_arr);
145+
takes_layout_asref(_arr.as_ref());
160146
}
161147

162148
/// Mutable, take a generic that implements `AsMut` to `RawRef`
163149
#[allow(dead_code)]
164150
fn takes_rawref_asmut<T, A, D>(_arr: &mut T)
165-
where T: AsMutRawRef<A, D> + ?Sized
151+
where T: AsMut<RawRef<A, D>> + ?Sized
166152
{
167153
takes_layout_mut(_arr.as_mut());
168-
takes_layout_asmut(_arr);
154+
takes_layout_asmut(_arr.as_mut());
169155
}
170156

171157
/// Finally, there's `LayoutRef`: this type provides read and write access to an array's *structure*, but not its *data*.
@@ -184,14 +170,14 @@ fn takes_layout_mut<A, D>(_arr: &mut LayoutRef<A, D>) {}
184170
/// Immutable, take a generic that implements `AsRef` to `LayoutRef`
185171
#[allow(dead_code)]
186172
fn takes_layout_asref<T, A, D>(_arr: &T)
187-
where T: AsLayoutRef<A, D> + ?Sized
173+
where T: AsRef<LayoutRef<A, D>> + ?Sized
188174
{
189175
}
190176

191177
/// Mutable, take a generic that implements `AsMut` to `LayoutRef`
192178
#[allow(dead_code)]
193179
fn takes_layout_asmut<T, A, D>(_arr: &mut T)
194-
where T: AsMutLayoutRef<A, D> + ?Sized
180+
where T: AsMut<LayoutRef<A, D>> + ?Sized
195181
{
196182
}
197183

src/arraytraits.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use std::{iter::FromIterator, slice};
1919
use crate::imp_prelude::*;
2020
use crate::Arc;
2121

22-
use crate::AsLayoutRef;
2322
use crate::{
2423
dimension,
2524
iter::{Iter, IterMut},
@@ -42,7 +41,7 @@ pub fn debug_bounds_check<A, D, I, T>(_a: &T, _index: &I)
4241
where
4342
D: Dimension,
4443
I: NdIndex<D>,
45-
T: AsLayoutRef<A, D> + ?Sized,
44+
T: AsRef<LayoutRef<A, D>> + ?Sized,
4645
{
4746
let layout_ref = _a.as_ref();
4847
debug_bounds_check_ref!(layout_ref, *_index);

src/free_functions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use std::compile_error;
1515
use std::mem::{forget, size_of};
1616
use std::ptr::NonNull;
1717

18-
use crate::{dimension, ArcArray1, ArcArray2, ArrayParts};
18+
use crate::{dimension, ArcArray1, ArcArray2};
1919
use crate::{imp_prelude::*, ArrayPartsSized};
2020

2121
/// Create an **[`Array`]** with one, two, three, four, five, or six dimensions.

src/impl_ref_types.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -395,21 +395,6 @@ where S: RawData<Elem = A>
395395
}
396396
}
397397

398-
macro_rules! blanket_ref_alias {
399-
($alias_name:ident, $alias_name_mut:ident, $target:ty) => {
400-
pub trait $alias_name<A, D>: AsRef<$target> {}
401-
402-
impl<T: ?Sized, A, D> $alias_name<A, D> for T where T: AsRef<$target> {}
403-
404-
pub trait $alias_name_mut<A, D>: AsMut<$target> {}
405-
406-
impl<T: ?Sized, A, D> $alias_name_mut<A, D> for T where T: AsMut<$target> {}
407-
};
408-
}
409-
410-
blanket_ref_alias!(AsLayoutRef, AsMutLayoutRef, LayoutRef<A, D>);
411-
blanket_ref_alias!(AsRawRef, AsMutRawRef, LayoutRef<A, D>);
412-
413398
/// Tests that a mem::swap can't compile by putting it into a doctest
414399
///
415400
/// ```compile_fail

src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ mod macro_utils;
172172
#[macro_use]
173173
mod private;
174174
mod impl_ref_types;
175-
pub use impl_ref_types::*;
176175
mod aliases;
177176
#[macro_use]
178177
mod itertools;

0 commit comments

Comments
 (0)