1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/*
    Appellation: reshape <mod>
    Contrib: FL03 <jo3mccain@icloud.com>
*/
use crate::shape::Axis;

pub trait Swap {
    type Key;

    fn swap(&mut self, swap: Self::Key, with: Self::Key);
}

impl<T> Swap for [T] {
    type Key = usize;

    fn swap(&mut self, swap: Self::Key, with: Self::Key) {
        self.swap(swap, with);
    }
}

pub trait SwapAxes {
    fn swap_axes(&self, swap: Axis, with: Axis) -> Self;
}