1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serialize", derive(Serialize, Deserialize))]
pub struct Handle(pub u64);

impl Handle {
    pub fn empty() -> Self {
        Handle(0)
    }
    pub fn next_handle_value(self) -> Self {
        Handle(self.0 + 1)
    }
    pub fn is_empty(self) -> bool {
        self.0 == 0
    }
    pub fn as_string(self) -> String {
        format!("{:X}", self.0)
    }
}