miden_stdlib_sys/intrinsics/
word.rs

1use core::ops::{Index, IndexMut};
2
3use crate::Felt;
4
5#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
6#[repr(C, align(32))]
7pub struct Word([Felt; 4]);
8impl Word {
9    pub const fn new(word: [Felt; 4]) -> Self {
10        Self(word)
11    }
12}
13impl From<[Felt; 4]> for Word {
14    fn from(word: [Felt; 4]) -> Self {
15        Self(word)
16    }
17}
18impl From<Word> for [Felt; 4] {
19    #[inline(always)]
20    fn from(word: Word) -> Self {
21        word.0
22    }
23}
24impl Index<usize> for Word {
25    type Output = Felt;
26
27    #[inline(always)]
28    fn index(&self, index: usize) -> &Self::Output {
29        self.0.index(index)
30    }
31}
32impl IndexMut<usize> for Word {
33    #[inline(always)]
34    fn index_mut(&mut self, index: usize) -> &mut Self::Output {
35        self.0.index_mut(index)
36    }
37}