slvm/heap/
handle.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct Handle {
    idx: u32,
}

impl Handle {
    pub fn new(idx: usize) -> Self {
        Self { idx: idx as u32 }
    }

    pub fn new32(idx: u32) -> Self {
        Self { idx }
    }

    pub fn idx(&self) -> usize {
        self.idx as usize
    }
}

impl From<u32> for Handle {
    fn from(idx: u32) -> Self {
        Self { idx }
    }
}