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
use core::ops::{Index, IndexMut};

use crate::Felt;

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C, align(32))]
pub struct Word([Felt; 4]);
impl Word {
    pub const fn new(word: [Felt; 4]) -> Self {
        Self(word)
    }
}
impl From<[Felt; 4]> for Word {
    fn from(word: [Felt; 4]) -> Self {
        Self(word)
    }
}
impl From<Word> for [Felt; 4] {
    #[inline(always)]
    fn from(word: Word) -> Self {
        word.0
    }
}
impl Index<usize> for Word {
    type Output = Felt;

    #[inline(always)]
    fn index(&self, index: usize) -> &Self::Output {
        self.0.index(index)
    }
}
impl IndexMut<usize> for Word {
    #[inline(always)]
    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
        self.0.index_mut(index)
    }
}