Skip to content

Commit

Permalink
Support for fixed sized arrays in models dojoengine#2785: Added intro…
Browse files Browse the repository at this point in the history
…spect
  • Loading branch information
bengineer42 committed Dec 31, 2024
1 parent 0cf1b45 commit 24ef8f3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions crates/dojo/core/src/meta/introspect.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,21 @@ pub impl Introspect_bool of Introspect<bool> {
}
}

pub impl Introspect_FixedArray<T, const N: usize, +Introspect<T>> of Introspect<[T; N]> {
fn size() -> Option<usize> {
match Introspect::<T>::size() {
Option::Some(size) => Option::Some(size * N),
Option::None => Option::None
}
}
fn layout() -> Layout {
Layout::FixedArray([(Introspect::<T>::layout(), N)].span())
}
fn ty() -> Ty {
Ty::FixedArray([(Introspect::<T>::ty(), N)].span())
}
}

pub impl Introspect_u8 of Introspect<u8> {
fn size() -> Option<usize> {
Option::Some(1)
Expand Down

0 comments on commit 24ef8f3

Please sign in to comment.