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 a VM word boundary
16/// (4 felts, with each felt stored in a `u64`, i.e. 32 bytes).
17#[repr(C, align(32))]
18pub struct WordAligned<T>(T);
19impl<T> WordAligned<T> {
20    #[inline(always)]
21    /// Wraps the provided value.
22    pub const fn new(t: T) -> Self {
23        Self(t)
24    }
25
26    #[inline(always)]
27    /// Returns the wrapped value.
28    pub fn into_inner(self) -> T {
29        self.0
30    }
31}
32impl<T> From<T> for WordAligned<T> {
33    #[inline(always)]
34    fn from(t: T) -> Self {
35        Self(t)
36    }
37}
38impl<T> AsRef<T> for WordAligned<T> {
39    #[inline(always)]
40    fn as_ref(&self) -> &T {
41        &self.0
42    }
43}
44impl<T> AsMut<T> for WordAligned<T> {
45    #[inline(always)]
46    fn as_mut(&mut self) -> &mut T {
47        &mut self.0
48    }
49}
50impl<T> Deref for WordAligned<T> {
51    type Target = T;
52
53    #[inline(always)]
54    fn deref(&self) -> &Self::Target {
55        &self.0
56    }
57}
58impl<T> DerefMut for WordAligned<T> {
59    #[inline(always)]
60    fn deref_mut(&mut self) -> &mut Self::Target {
61        &mut self.0
62    }
63}