1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
   Appellation: adjust <traits>
   Contrib: FL03 <jo3mccain@icloud.com>
*/
use nd::{Axis, RemoveAxis};

/// Decrement generally describes an object capable of _decrementing_ itself;
///
/// Here, it is used on a [Dimension](ndarray::Dimension) enabling it to
/// remove and return an axis from itself.
pub trait Decrement {
    type Output;

    fn dec(&self) -> Self::Output;
}

pub trait Increment {
    type Output;

    fn inc(&self) -> Self::Output;
}

/*
 ******** implementations ********
*/
impl<D> Decrement for D
where
    D: RemoveAxis,
{
    type Output = D::Smaller;

    fn dec(&self) -> Self::Output {
        self.remove_axis(Axis(self.ndim() - 1))
    }
}