Skip to main content

miden_stdlib_sys/intrinsics/
mod.rs

1use core::ops::{Deref, DerefMut};
2
3pub use miden_field::Word;
4
5pub use self::{
6    crypto::Digest,
7    felt::{Felt, assert, assert_eq, assertz},
8};
9
10pub mod advice;
11pub mod crypto;
12pub mod debug;
13pub mod felt;
14
15/// A wrapper type which ensures that the wrapped value is aligned to 32 bytes.
16#[repr(C, align(32))]
17pub struct WordAligned<T>(T);
18impl<T> WordAligned<T> {
19    #[inline(always)]
20    /// Wraps the provided value.
21    pub const fn new(t: T) -> Self {
22        Self(t)
23    }
24
25    #[inline(always)]
26    /// Returns the wrapped value.
27    pub fn into_inner(self) -> T {
28        self.0
29    }
30}
31impl<T> From<T> for WordAligned<T> {
32    #[inline(always)]
33    fn from(t: T) -> Self {
34        Self(t)
35    }
36}
37impl<T> AsRef<T> for WordAligned<T> {
38    #[inline(always)]
39    fn as_ref(&self) -> &T {
40        &self.0
41    }
42}
43impl<T> AsMut<T> for WordAligned<T> {
44    #[inline(always)]
45    fn as_mut(&mut self) -> &mut T {
46        &mut self.0
47    }
48}
49impl<T> Deref for WordAligned<T> {
50    type Target = T;
51
52    #[inline(always)]
53    fn deref(&self) -> &Self::Target {
54        &self.0
55    }
56}
57impl<T> DerefMut for WordAligned<T> {
58    #[inline(always)]
59    fn deref_mut(&mut self) -> &mut Self::Target {
60        &mut self.0
61    }
62}