shex_ast/ir/
shape_label_idx.rs

1use std::fmt::Display;
2
3use rbe::Ref;
4use serde::Serialize;
5
6#[derive(PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Copy, Debug, Default, Serialize)]
7pub struct ShapeLabelIdx(usize);
8
9impl Ref for ShapeLabelIdx {}
10
11impl ShapeLabelIdx {
12    pub fn incr(&mut self) {
13        self.0 += 1;
14    }
15
16    pub fn error() -> ShapeLabelIdx {
17        ShapeLabelIdx(0)
18    }
19}
20
21impl Display for ShapeLabelIdx {
22    fn fmt(&self, dest: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
23        write!(dest, "{}", self.0)
24    }
25}
26
27impl From<usize> for ShapeLabelIdx {
28    fn from(idx: usize) -> Self {
29        ShapeLabelIdx(idx)
30    }
31}