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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use std::fmt::Debug;

/// Array format trait.
pub trait Format: Copy + Debug + Default {
    /// General or strided array format.
    type NonDense: NonDense;

    /// Dense or general array format.
    type UnitStrided: UnitStrided;
}

/// General or strided array format trait.
pub trait NonDense: Format {}

/// Dense or general array format trait.
pub trait UnitStrided: Format {}

/// Dense array format type.
#[derive(Clone, Copy, Debug, Default)]
pub struct Dense;

/// General array format type.
#[derive(Clone, Copy, Debug, Default)]
pub struct General;

/// Strided array format type.
#[derive(Clone, Copy, Debug, Default)]
pub struct Strided;

impl Format for Dense {
    type NonDense = General;
    type UnitStrided = Dense;
}

impl Format for General {
    type NonDense = General;
    type UnitStrided = General;
}

impl Format for Strided {
    type NonDense = Strided;
    type UnitStrided = General;
}

impl NonDense for General {}
impl NonDense for Strided {}

impl UnitStrided for Dense {}
impl UnitStrided for General {}