Skip to main content

luaur_code_gen/records/
block_iterator_wrapper.rs

1#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2pub struct BlockIteratorWrapper {
3    pub(crate) itBegin: *const u32,
4    pub(crate) itEnd: *const u32,
5}
6
7impl Default for BlockIteratorWrapper {
8    fn default() -> Self {
9        Self {
10            itBegin: core::ptr::null(),
11            itEnd: core::ptr::null(),
12        }
13    }
14}
15
16impl Iterator for BlockIteratorWrapper {
17    type Item = u32;
18
19    fn next(&mut self) -> Option<u32> {
20        if self.itBegin < self.itEnd {
21            let value = unsafe { *self.itBegin };
22            self.itBegin = unsafe { self.itBegin.add(1) };
23            Some(value)
24        } else {
25            None
26        }
27    }
28}