@@ -75,7 +75,7 @@ pub struct NewAxis;
75
75
/// A slice (range with step), an index, or a new axis token.
76
76
///
77
77
/// 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 >`.
79
79
///
80
80
/// ## Examples
81
81
///
@@ -316,12 +316,12 @@ pub unsafe trait CanSlice<D: Dimension>: AsRef<[AxisSliceInfo]> {
316
316
317
317
macro_rules! impl_canslice_samedim {
318
318
( $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 >
320
320
where
321
321
T : AsRef <[ AxisSliceInfo ] >,
322
- Do : Dimension ,
322
+ Dout : Dimension ,
323
323
{
324
- type OutDim = Do ;
324
+ type OutDim = Dout ;
325
325
326
326
fn in_ndim( & self ) -> usize {
327
327
self . in_ndim( )
@@ -341,13 +341,13 @@ impl_canslice_samedim!(Ix4);
341
341
impl_canslice_samedim ! ( Ix5 ) ;
342
342
impl_canslice_samedim ! ( Ix6 ) ;
343
343
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 >
345
345
where
346
346
T : AsRef < [ AxisSliceInfo ] > ,
347
- Di : Dimension ,
348
- Do : Dimension ,
347
+ Din : Dimension ,
348
+ Dout : Dimension ,
349
349
{
350
- type OutDim = Do ;
350
+ type OutDim = Dout ;
351
351
352
352
fn in_ndim ( & self ) -> usize {
353
353
self . in_ndim ( )
@@ -361,36 +361,36 @@ where
361
361
/// Represents all of the necessary information to perform a slice.
362
362
///
363
363
/// 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
367
367
/// `SliceInfo` instance can still be used to slice an array with dimension
368
368
/// `IxDyn` as long as the number of axes matches.
369
369
///
370
370
/// [`.slice()`]: struct.ArrayBase.html#method.slice
371
371
#[ derive( Debug ) ]
372
372
#[ 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 > ,
376
376
indices : T ,
377
377
}
378
378
379
- impl < T : ?Sized , Di , Do > Deref for SliceInfo < T , Di , Do >
379
+ impl < T : ?Sized , Din , Dout > Deref for SliceInfo < T , Din , Dout >
380
380
where
381
- Di : Dimension ,
382
- Do : Dimension ,
381
+ Din : Dimension ,
382
+ Dout : Dimension ,
383
383
{
384
384
type Target = T ;
385
385
fn deref ( & self ) -> & Self :: Target {
386
386
& self . indices
387
387
}
388
388
}
389
389
390
- impl < T , Di , Do > SliceInfo < T , Di , Do >
390
+ impl < T , Din , Dout > SliceInfo < T , Din , Dout >
391
391
where
392
- Di : Dimension ,
393
- Do : Dimension ,
392
+ Din : Dimension ,
393
+ Dout : Dimension ,
394
394
{
395
395
/// Returns a new `SliceInfo` instance.
396
396
///
@@ -399,9 +399,9 @@ where
399
399
#[ doc( hidden) ]
400
400
pub unsafe fn new_unchecked (
401
401
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 > {
405
405
SliceInfo {
406
406
in_dim : in_dim,
407
407
out_dim : out_dim,
@@ -410,22 +410,22 @@ where
410
410
}
411
411
}
412
412
413
- impl < T , Di , Do > SliceInfo < T , Di , Do >
413
+ impl < T , Din , Dout > SliceInfo < T , Din , Dout >
414
414
where
415
415
T : AsRef < [ AxisSliceInfo ] > ,
416
- Di : Dimension ,
417
- Do : Dimension ,
416
+ Din : Dimension ,
417
+ Dout : Dimension ,
418
418
{
419
419
/// Returns a new `SliceInfo` instance.
420
420
///
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 {
424
424
if ndim != indices. as_ref ( ) . iter ( ) . filter ( |s| !s. is_new_axis ( ) ) . count ( ) {
425
425
return Err ( ShapeError :: from_kind ( ErrorKind :: IncompatibleShape ) ) ;
426
426
}
427
427
}
428
- if let Some ( ndim) = Do :: NDIM {
428
+ if let Some ( ndim) = Dout :: NDIM {
429
429
if ndim != indices. as_ref ( ) . iter ( ) . filter ( |s| !s. is_index ( ) ) . count ( ) {
430
430
return Err ( ShapeError :: from_kind ( ErrorKind :: IncompatibleShape ) ) ;
431
431
}
@@ -438,20 +438,20 @@ where
438
438
}
439
439
}
440
440
441
- impl < T : ?Sized , Di , Do > SliceInfo < T , Di , Do >
441
+ impl < T : ?Sized , Din , Dout > SliceInfo < T , Din , Dout >
442
442
where
443
443
T : AsRef < [ AxisSliceInfo ] > ,
444
- Di : Dimension ,
445
- Do : Dimension ,
444
+ Din : Dimension ,
445
+ Dout : Dimension ,
446
446
{
447
447
/// Returns the number of dimensions of the input array for
448
448
/// [`.slice()`](struct.ArrayBase.html#method.slice).
449
449
///
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
452
452
/// over the `AxisSliceInfo` elements.
453
453
pub fn in_ndim ( & self ) -> usize {
454
- Di :: NDIM . unwrap_or_else ( || {
454
+ Din :: NDIM . unwrap_or_else ( || {
455
455
self . indices
456
456
. as_ref ( )
457
457
. iter ( )
@@ -464,11 +464,11 @@ where
464
464
/// [`.slice()`](struct.ArrayBase.html#method.slice) (including taking
465
465
/// subviews).
466
466
///
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
469
469
/// over the `AxisSliceInfo` elements.
470
470
pub fn out_ndim ( & self ) -> usize {
471
- Do :: NDIM . unwrap_or_else ( || {
471
+ Dout :: NDIM . unwrap_or_else ( || {
472
472
self . indices
473
473
. as_ref ( )
474
474
. iter ( )
@@ -478,48 +478,48 @@ where
478
478
}
479
479
}
480
480
481
- impl < T , Di , Do > AsRef < [ AxisSliceInfo ] > for SliceInfo < T , Di , Do >
481
+ impl < T , Din , Dout > AsRef < [ AxisSliceInfo ] > for SliceInfo < T , Din , Dout >
482
482
where
483
483
T : AsRef < [ AxisSliceInfo ] > ,
484
- Di : Dimension ,
485
- Do : Dimension ,
484
+ Din : Dimension ,
485
+ Dout : Dimension ,
486
486
{
487
487
fn as_ref ( & self ) -> & [ AxisSliceInfo ] {
488
488
self . indices . as_ref ( )
489
489
}
490
490
}
491
491
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 >
493
493
where
494
494
T : AsRef < [ AxisSliceInfo ] > ,
495
- Di : Dimension ,
496
- Do : Dimension ,
495
+ Din : Dimension ,
496
+ Dout : Dimension ,
497
497
{
498
- fn as_ref ( & self ) -> & SliceInfo < [ AxisSliceInfo ] , Di , Do > {
498
+ fn as_ref ( & self ) -> & SliceInfo < [ AxisSliceInfo ] , Din , Dout > {
499
499
unsafe {
500
500
// 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 >`
502
502
// should have the same bitwise representation as
503
503
// `&[AxisSliceInfo]`.
504
504
& * ( self . indices . as_ref ( ) as * const [ AxisSliceInfo ]
505
- as * const SliceInfo < [ AxisSliceInfo ] , Di , Do > )
505
+ as * const SliceInfo < [ AxisSliceInfo ] , Din , Dout > )
506
506
}
507
507
}
508
508
}
509
509
510
- impl < T , Di , Do > Copy for SliceInfo < T , Di , Do >
510
+ impl < T , Din , Dout > Copy for SliceInfo < T , Din , Dout >
511
511
where
512
512
T : Copy ,
513
- Di : Dimension ,
514
- Do : Dimension ,
513
+ Din : Dimension ,
514
+ Dout : Dimension ,
515
515
{
516
516
}
517
517
518
- impl < T , Di , Do > Clone for SliceInfo < T , Di , Do >
518
+ impl < T , Din , Dout > Clone for SliceInfo < T , Din , Dout >
519
519
where
520
520
T : Clone ,
521
- Di : Dimension ,
522
- Do : Dimension ,
521
+ Din : Dimension ,
522
+ Dout : Dimension ,
523
523
{
524
524
fn clone ( & self ) -> Self {
525
525
SliceInfo {
0 commit comments