slvm/heap/handle.rs
1#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
2pub struct Handle {
3 idx: u32,
4}
5
6impl Handle {
7 pub fn new(idx: usize) -> Self {
8 Self { idx: idx as u32 }
9 }
10
11 pub fn new32(idx: u32) -> Self {
12 Self { idx }
13 }
14
15 pub fn idx(&self) -> usize {
16 self.idx as usize
17 }
18}
19
20impl From<u32> for Handle {
21 fn from(idx: u32) -> Self {
22 Self { idx }
23 }
24}