Skip to content

Commit d7039a0

Browse files
committed
Rename SliceInfo generic params to Din and Dout
1 parent 9de552f commit d7039a0

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

src/slice.rs

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub struct NewAxis;
7575
/// A slice (range with step), an index, or a new axis token.
7676
///
7777
/// See also the [`s![]`](macro.s!.html) macro for a convenient way to create a
78-
/// `&SliceInfo<[AxisSliceInfo; n], Di, Do>`.
78+
/// `&SliceInfo<[AxisSliceInfo; n], Din, Dout>`.
7979
///
8080
/// ## Examples
8181
///
@@ -316,12 +316,12 @@ pub unsafe trait CanSlice<D: Dimension>: AsRef<[AxisSliceInfo]> {
316316

317317
macro_rules! impl_canslice_samedim {
318318
($in_dim:ty) => {
319-
unsafe impl<T, Do> CanSlice<$in_dim> for SliceInfo<T, $in_dim, Do>
319+
unsafe impl<T, Dout> CanSlice<$in_dim> for SliceInfo<T, $in_dim, Dout>
320320
where
321321
T: AsRef<[AxisSliceInfo]>,
322-
Do: Dimension,
322+
Dout: Dimension,
323323
{
324-
type OutDim = Do;
324+
type OutDim = Dout;
325325

326326
fn in_ndim(&self) -> usize {
327327
self.in_ndim()
@@ -341,13 +341,13 @@ impl_canslice_samedim!(Ix4);
341341
impl_canslice_samedim!(Ix5);
342342
impl_canslice_samedim!(Ix6);
343343

344-
unsafe impl<T, Di, Do> CanSlice<IxDyn> for SliceInfo<T, Di, Do>
344+
unsafe impl<T, Din, Dout> CanSlice<IxDyn> for SliceInfo<T, Din, Dout>
345345
where
346346
T: AsRef<[AxisSliceInfo]>,
347-
Di: Dimension,
348-
Do: Dimension,
347+
Din: Dimension,
348+
Dout: Dimension,
349349
{
350-
type OutDim = Do;
350+
type OutDim = Dout;
351351

352352
fn in_ndim(&self) -> usize {
353353
self.in_ndim()
@@ -361,36 +361,36 @@ where
361361
/// Represents all of the necessary information to perform a slice.
362362
///
363363
/// The type `T` is typically `[AxisSliceInfo; n]`, `[AxisSliceInfo]`, or
364-
/// `Vec<AxisSliceInfo>`. The type `Di` is the dimension of the array to be
365-
/// sliced, and `Do` is the output dimension after calling [`.slice()`]. Note
366-
/// that if `Di` is a fixed dimension type (`Ix0`, `Ix1`, `Ix2`, etc.), the
364+
/// `Vec<AxisSliceInfo>`. The type `Din` is the dimension of the array to be
365+
/// sliced, and `Dout` is the output dimension after calling [`.slice()`]. Note
366+
/// that if `Din` is a fixed dimension type (`Ix0`, `Ix1`, `Ix2`, etc.), the
367367
/// `SliceInfo` instance can still be used to slice an array with dimension
368368
/// `IxDyn` as long as the number of axes matches.
369369
///
370370
/// [`.slice()`]: struct.ArrayBase.html#method.slice
371371
#[derive(Debug)]
372372
#[repr(C)]
373-
pub struct SliceInfo<T: ?Sized, Di: Dimension, Do: Dimension> {
374-
in_dim: PhantomData<Di>,
375-
out_dim: PhantomData<Do>,
373+
pub struct SliceInfo<T: ?Sized, Din: Dimension, Dout: Dimension> {
374+
in_dim: PhantomData<Din>,
375+
out_dim: PhantomData<Dout>,
376376
indices: T,
377377
}
378378

379-
impl<T: ?Sized, Di, Do> Deref for SliceInfo<T, Di, Do>
379+
impl<T: ?Sized, Din, Dout> Deref for SliceInfo<T, Din, Dout>
380380
where
381-
Di: Dimension,
382-
Do: Dimension,
381+
Din: Dimension,
382+
Dout: Dimension,
383383
{
384384
type Target = T;
385385
fn deref(&self) -> &Self::Target {
386386
&self.indices
387387
}
388388
}
389389

390-
impl<T, Di, Do> SliceInfo<T, Di, Do>
390+
impl<T, Din, Dout> SliceInfo<T, Din, Dout>
391391
where
392-
Di: Dimension,
393-
Do: Dimension,
392+
Din: Dimension,
393+
Dout: Dimension,
394394
{
395395
/// Returns a new `SliceInfo` instance.
396396
///
@@ -399,9 +399,9 @@ where
399399
#[doc(hidden)]
400400
pub unsafe fn new_unchecked(
401401
indices: T,
402-
in_dim: PhantomData<Di>,
403-
out_dim: PhantomData<Do>,
404-
) -> SliceInfo<T, Di, Do> {
402+
in_dim: PhantomData<Din>,
403+
out_dim: PhantomData<Dout>,
404+
) -> SliceInfo<T, Din, Dout> {
405405
SliceInfo {
406406
in_dim: in_dim,
407407
out_dim: out_dim,
@@ -410,22 +410,22 @@ where
410410
}
411411
}
412412

413-
impl<T, Di, Do> SliceInfo<T, Di, Do>
413+
impl<T, Din, Dout> SliceInfo<T, Din, Dout>
414414
where
415415
T: AsRef<[AxisSliceInfo]>,
416-
Di: Dimension,
417-
Do: Dimension,
416+
Din: Dimension,
417+
Dout: Dimension,
418418
{
419419
/// Returns a new `SliceInfo` instance.
420420
///
421-
/// Errors if `Di` or `Do` is not consistent with `indices`.
422-
pub fn new(indices: T) -> Result<SliceInfo<T, Di, Do>, ShapeError> {
423-
if let Some(ndim) = Di::NDIM {
421+
/// Errors if `Din` or `Dout` is not consistent with `indices`.
422+
pub fn new(indices: T) -> Result<SliceInfo<T, Din, Dout>, ShapeError> {
423+
if let Some(ndim) = Din::NDIM {
424424
if ndim != indices.as_ref().iter().filter(|s| !s.is_new_axis()).count() {
425425
return Err(ShapeError::from_kind(ErrorKind::IncompatibleShape));
426426
}
427427
}
428-
if let Some(ndim) = Do::NDIM {
428+
if let Some(ndim) = Dout::NDIM {
429429
if ndim != indices.as_ref().iter().filter(|s| !s.is_index()).count() {
430430
return Err(ShapeError::from_kind(ErrorKind::IncompatibleShape));
431431
}
@@ -438,20 +438,20 @@ where
438438
}
439439
}
440440

441-
impl<T: ?Sized, Di, Do> SliceInfo<T, Di, Do>
441+
impl<T: ?Sized, Din, Dout> SliceInfo<T, Din, Dout>
442442
where
443443
T: AsRef<[AxisSliceInfo]>,
444-
Di: Dimension,
445-
Do: Dimension,
444+
Din: Dimension,
445+
Dout: Dimension,
446446
{
447447
/// Returns the number of dimensions of the input array for
448448
/// [`.slice()`](struct.ArrayBase.html#method.slice).
449449
///
450-
/// If `Di` is a fixed-size dimension type, then this is equivalent to
451-
/// `Di::NDIM.unwrap()`. Otherwise, the value is calculated by iterating
450+
/// If `Din` is a fixed-size dimension type, then this is equivalent to
451+
/// `Din::NDIM.unwrap()`. Otherwise, the value is calculated by iterating
452452
/// over the `AxisSliceInfo` elements.
453453
pub fn in_ndim(&self) -> usize {
454-
Di::NDIM.unwrap_or_else(|| {
454+
Din::NDIM.unwrap_or_else(|| {
455455
self.indices
456456
.as_ref()
457457
.iter()
@@ -464,11 +464,11 @@ where
464464
/// [`.slice()`](struct.ArrayBase.html#method.slice) (including taking
465465
/// subviews).
466466
///
467-
/// If `Do` is a fixed-size dimension type, then this is equivalent to
468-
/// `Do::NDIM.unwrap()`. Otherwise, the value is calculated by iterating
467+
/// If `Dout` is a fixed-size dimension type, then this is equivalent to
468+
/// `Dout::NDIM.unwrap()`. Otherwise, the value is calculated by iterating
469469
/// over the `AxisSliceInfo` elements.
470470
pub fn out_ndim(&self) -> usize {
471-
Do::NDIM.unwrap_or_else(|| {
471+
Dout::NDIM.unwrap_or_else(|| {
472472
self.indices
473473
.as_ref()
474474
.iter()
@@ -478,48 +478,48 @@ where
478478
}
479479
}
480480

481-
impl<T, Di, Do> AsRef<[AxisSliceInfo]> for SliceInfo<T, Di, Do>
481+
impl<T, Din, Dout> AsRef<[AxisSliceInfo]> for SliceInfo<T, Din, Dout>
482482
where
483483
T: AsRef<[AxisSliceInfo]>,
484-
Di: Dimension,
485-
Do: Dimension,
484+
Din: Dimension,
485+
Dout: Dimension,
486486
{
487487
fn as_ref(&self) -> &[AxisSliceInfo] {
488488
self.indices.as_ref()
489489
}
490490
}
491491

492-
impl<T, Di, Do> AsRef<SliceInfo<[AxisSliceInfo], Di, Do>> for SliceInfo<T, Di, Do>
492+
impl<T, Din, Dout> AsRef<SliceInfo<[AxisSliceInfo], Din, Dout>> for SliceInfo<T, Din, Dout>
493493
where
494494
T: AsRef<[AxisSliceInfo]>,
495-
Di: Dimension,
496-
Do: Dimension,
495+
Din: Dimension,
496+
Dout: Dimension,
497497
{
498-
fn as_ref(&self) -> &SliceInfo<[AxisSliceInfo], Di, Do> {
498+
fn as_ref(&self) -> &SliceInfo<[AxisSliceInfo], Din, Dout> {
499499
unsafe {
500500
// This is okay because the only non-zero-sized member of
501-
// `SliceInfo` is `indices`, so `&SliceInfo<[AxisSliceInfo], Di, Do>`
501+
// `SliceInfo` is `indices`, so `&SliceInfo<[AxisSliceInfo], Din, Dout>`
502502
// should have the same bitwise representation as
503503
// `&[AxisSliceInfo]`.
504504
&*(self.indices.as_ref() as *const [AxisSliceInfo]
505-
as *const SliceInfo<[AxisSliceInfo], Di, Do>)
505+
as *const SliceInfo<[AxisSliceInfo], Din, Dout>)
506506
}
507507
}
508508
}
509509

510-
impl<T, Di, Do> Copy for SliceInfo<T, Di, Do>
510+
impl<T, Din, Dout> Copy for SliceInfo<T, Din, Dout>
511511
where
512512
T: Copy,
513-
Di: Dimension,
514-
Do: Dimension,
513+
Din: Dimension,
514+
Dout: Dimension,
515515
{
516516
}
517517

518-
impl<T, Di, Do> Clone for SliceInfo<T, Di, Do>
518+
impl<T, Din, Dout> Clone for SliceInfo<T, Din, Dout>
519519
where
520520
T: Clone,
521-
Di: Dimension,
522-
Do: Dimension,
521+
Din: Dimension,
522+
Dout: Dimension,
523523
{
524524
fn clone(&self) -> Self {
525525
SliceInfo {

0 commit comments

Comments
 (0)