concision_core/traits/misc/adjust.rs
1/*
2 Appellation: adjust <traits>
3 Contrib: FL03 <jo3mccain@icloud.com>
4*/
5use nd::{Axis, RemoveAxis};
6
7/// Decrement generally describes an object capable of _decrementing_ itself;
8///
9/// Here, it is used on a [Dimension](ndarray::Dimension) enabling it to
10/// remove and return an axis from itself.
11pub trait Decrement {
12 type Output;
13
14 fn dec(&self) -> Self::Output;
15}
16
17pub trait Increment {
18 type Output;
19
20 fn inc(&self) -> Self::Output;
21}
22
23/*
24 ******** implementations ********
25*/
26impl<D> Decrement for D
27where
28 D: RemoveAxis,
29{
30 type Output = D::Smaller;
31
32 fn dec(&self) -> Self::Output {
33 self.remove_axis(Axis(self.ndim() - 1))
34 }
35}