Skip to content

Commit f9ddada

Browse files
jturner314bluss
authored andcommitted
Rename CanSlice to SliceArg
1 parent f2e5283 commit f9ddada

File tree

5 files changed

+30
-43
lines changed

5 files changed

+30
-43
lines changed

src/dimension/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// except according to those terms.
88

99
use crate::error::{from_kind, ErrorKind, ShapeError};
10-
use crate::slice::CanSlice;
10+
use crate::slice::SliceArg;
1111
use crate::{AxisSliceInfo, Ix, Ixs, Slice};
1212
use num_integer::div_floor;
1313

@@ -599,8 +599,8 @@ fn slice_min_max(axis_len: usize, slice: Slice) -> Option<(usize, usize)> {
599599
/// Returns `true` iff the slices intersect.
600600
pub fn slices_intersect<D: Dimension>(
601601
dim: &D,
602-
indices1: &impl CanSlice<D>,
603-
indices2: &impl CanSlice<D>,
602+
indices1: &impl SliceArg<D>,
603+
indices2: &impl SliceArg<D>,
604604
) -> bool {
605605
debug_assert_eq!(indices1.in_ndim(), indices2.in_ndim());
606606
for (&axis_len, &si1, &si2) in izip!(

src/impl_methods.rs

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use crate::iter::{
3232
AxisChunksIter, AxisChunksIterMut, AxisIter, AxisIterMut, ExactChunks, ExactChunksMut,
3333
IndexedIter, IndexedIterMut, Iter, IterMut, Lanes, LanesMut, Windows,
3434
};
35-
use crate::slice::{CanSlice, MultiSlice};
35+
use crate::slice::{MultiSlice, SliceArg};
3636
use crate::stacking::concatenate;
3737
use crate::{AxisSliceInfo, NdIndex, Slice};
3838

@@ -334,16 +334,13 @@ where
334334
/// Return a sliced view of the array.
335335
///
336336
/// See [*Slicing*](#slicing) for full documentation.
337-
/// See also [`SliceInfo`] and [`D::SliceArg`].
338-
///
339-
/// [`SliceInfo`]: struct.SliceInfo.html
340-
/// [`D::SliceArg`]: trait.Dimension.html#associatedtype.SliceArg
337+
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
341338
///
342339
/// **Panics** if an index is out of bounds or step size is zero.<br>
343340
/// (**Panics** if `D` is `IxDyn` and `info` does not match the number of array axes.)
344341
pub fn slice<I>(&self, info: &I) -> ArrayView<'_, A, I::OutDim>
345342
where
346-
I: CanSlice<D> + ?Sized,
343+
I: SliceArg<D> + ?Sized,
347344
S: Data,
348345
{
349346
self.view().slice_move(info)
@@ -352,16 +349,13 @@ where
352349
/// Return a sliced read-write view of the array.
353350
///
354351
/// See [*Slicing*](#slicing) for full documentation.
355-
/// See also [`SliceInfo`] and [`D::SliceArg`].
356-
///
357-
/// [`SliceInfo`]: struct.SliceInfo.html
358-
/// [`D::SliceArg`]: trait.Dimension.html#associatedtype.SliceArg
352+
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
359353
///
360354
/// **Panics** if an index is out of bounds or step size is zero.<br>
361355
/// (**Panics** if `D` is `IxDyn` and `info` does not match the number of array axes.)
362356
pub fn slice_mut<I>(&mut self, info: &I) -> ArrayViewMut<'_, A, I::OutDim>
363357
where
364-
I: CanSlice<D> + ?Sized,
358+
I: SliceArg<D> + ?Sized,
365359
S: DataMut,
366360
{
367361
self.view_mut().slice_move(info)
@@ -370,10 +364,7 @@ where
370364
/// Return multiple disjoint, sliced, mutable views of the array.
371365
///
372366
/// See [*Slicing*](#slicing) for full documentation.
373-
/// See also [`SliceInfo`] and [`D::SliceArg`].
374-
///
375-
/// [`SliceInfo`]: struct.SliceInfo.html
376-
/// [`D::SliceArg`]: trait.Dimension.html#associatedtype.SliceArg
367+
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
377368
///
378369
/// **Panics** if any of the following occur:
379370
///
@@ -403,16 +394,13 @@ where
403394
/// Slice the array, possibly changing the number of dimensions.
404395
///
405396
/// See [*Slicing*](#slicing) for full documentation.
406-
/// See also [`SliceInfo`] and [`D::SliceArg`].
407-
///
408-
/// [`SliceInfo`]: struct.SliceInfo.html
409-
/// [`D::SliceArg`]: trait.Dimension.html#associatedtype.SliceArg
397+
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
410398
///
411399
/// **Panics** if an index is out of bounds or step size is zero.<br>
412400
/// (**Panics** if `D` is `IxDyn` and `info` does not match the number of array axes.)
413401
pub fn slice_move<I>(mut self, info: &I) -> ArrayBase<S, I::OutDim>
414402
where
415-
I: CanSlice<D> + ?Sized,
403+
I: SliceArg<D> + ?Sized,
416404
{
417405
assert_eq!(
418406
info.in_ndim(),
@@ -462,6 +450,7 @@ where
462450
/// Slice the array in place without changing the number of dimensions.
463451
///
464452
/// See [*Slicing*](#slicing) for full documentation.
453+
/// See also [`s!`], [`SliceArg`], and [`SliceInfo`](crate::SliceInfo).
465454
///
466455
/// **Panics** in the following cases:
467456
///
@@ -472,7 +461,7 @@ where
472461
/// - if `D` is `IxDyn` and `info` does not match the number of array axes
473462
pub fn slice_collapse<I>(&mut self, info: &I)
474463
where
475-
I: CanSlice<D> + ?Sized,
464+
I: SliceArg<D> + ?Sized,
476465
{
477466
assert_eq!(
478467
info.in_ndim(),

src/impl_views/splitting.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,10 @@ where
117117
/// consumes `self` and produces views with lifetimes matching that of
118118
/// `self`.
119119
///
120-
/// See [*Slicing*](#slicing) for full documentation.
121-
/// See also [`SliceInfo`] and [`D::SliceArg`].
120+
/// See [*Slicing*](#slicing) for full documentation. See also [`s!`],
121+
/// [`SliceArg`](crate::SliceArg), and [`SliceInfo`](crate::SliceInfo).
122122
///
123123
/// [`.multi_slice_mut()`]: struct.ArrayBase.html#method.multi_slice_mut
124-
/// [`SliceInfo`]: struct.SliceInfo.html
125-
/// [`D::SliceArg`]: trait.Dimension.html#associatedtype.SliceArg
126124
///
127125
/// **Panics** if any of the following occur:
128126
///

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ pub use crate::dimension::NdIndex;
142142
pub use crate::error::{ErrorKind, ShapeError};
143143
pub use crate::indexes::{indices, indices_of};
144144
pub use crate::slice::{
145-
AxisSliceInfo, CanSlice, MultiSlice, NewAxis, Slice, SliceInfo, SliceNextDim,
145+
AxisSliceInfo, MultiSlice, NewAxis, Slice, SliceArg, SliceInfo, SliceNextDim,
146146
};
147147

148148
use crate::iterators::Baseiter;

src/slice.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl From<NewAxis> for AxisSliceInfo {
311311
/// that `D`, `Self::OutDim`, `self.in_dim()`, and `self.out_ndim()` are
312312
/// consistent with the `&[AxisSliceInfo]` returned by `self.as_ref()` and that
313313
/// `self.as_ref()` always returns the same value when called multiple times.
314-
pub unsafe trait CanSlice<D: Dimension>: AsRef<[AxisSliceInfo]> {
314+
pub unsafe trait SliceArg<D: Dimension>: AsRef<[AxisSliceInfo]> {
315315
/// Dimensionality of the output array.
316316
type OutDim: Dimension;
317317

@@ -324,9 +324,9 @@ pub unsafe trait CanSlice<D: Dimension>: AsRef<[AxisSliceInfo]> {
324324
private_decl! {}
325325
}
326326

327-
macro_rules! impl_canslice_samedim {
327+
macro_rules! impl_slicearg_samedim {
328328
($in_dim:ty) => {
329-
unsafe impl<T, Dout> CanSlice<$in_dim> for SliceInfo<T, $in_dim, Dout>
329+
unsafe impl<T, Dout> SliceArg<$in_dim> for SliceInfo<T, $in_dim, Dout>
330330
where
331331
T: AsRef<[AxisSliceInfo]>,
332332
Dout: Dimension,
@@ -345,15 +345,15 @@ macro_rules! impl_canslice_samedim {
345345
}
346346
};
347347
}
348-
impl_canslice_samedim!(Ix0);
349-
impl_canslice_samedim!(Ix1);
350-
impl_canslice_samedim!(Ix2);
351-
impl_canslice_samedim!(Ix3);
352-
impl_canslice_samedim!(Ix4);
353-
impl_canslice_samedim!(Ix5);
354-
impl_canslice_samedim!(Ix6);
348+
impl_slicearg_samedim!(Ix0);
349+
impl_slicearg_samedim!(Ix1);
350+
impl_slicearg_samedim!(Ix2);
351+
impl_slicearg_samedim!(Ix3);
352+
impl_slicearg_samedim!(Ix4);
353+
impl_slicearg_samedim!(Ix5);
354+
impl_slicearg_samedim!(Ix6);
355355

356-
unsafe impl<T, Din, Dout> CanSlice<IxDyn> for SliceInfo<T, Din, Dout>
356+
unsafe impl<T, Din, Dout> SliceArg<IxDyn> for SliceInfo<T, Din, Dout>
357357
where
358358
T: AsRef<[AxisSliceInfo]>,
359359
Din: Dimension,
@@ -372,7 +372,7 @@ where
372372
private_impl! {}
373373
}
374374

375-
unsafe impl CanSlice<IxDyn> for [AxisSliceInfo] {
375+
unsafe impl SliceArg<IxDyn> for [AxisSliceInfo] {
376376
type OutDim = IxDyn;
377377

378378
fn in_ndim(&self) -> usize {
@@ -937,7 +937,7 @@ impl<'a, A, D, I0> MultiSlice<'a, A, D> for (&I0,)
937937
where
938938
A: 'a,
939939
D: Dimension,
940-
I0: CanSlice<D>,
940+
I0: SliceArg<D>,
941941
{
942942
type Output = (ArrayViewMut<'a, A, I0::OutDim>,);
943943

@@ -957,7 +957,7 @@ macro_rules! impl_multislice_tuple {
957957
where
958958
A: 'a,
959959
D: Dimension,
960-
$($all: CanSlice<D>,)*
960+
$($all: SliceArg<D>,)*
961961
{
962962
type Output = ($(ArrayViewMut<'a, A, $all::OutDim>,)*);
963963

0 commit comments

Comments
 (0)