1#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
7pub struct FieldId(pub u16);
8
9impl FieldId {
10 pub const fn new(id: u16) -> Self {
11 Self(id)
12 }
13
14 pub const fn as_u16(self) -> u16 {
15 self.0
16 }
17}
18
19impl std::fmt::Display for FieldId {
20 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
21 write!(f, "{}", self.0)
22 }
23}
24
25#[cfg(test)]
26mod tests {
27 use super::*;
28
29 #[test]
30 fn ordering() {
31 assert!(FieldId(0) < FieldId(1));
32 assert!(FieldId(1) < FieldId(100));
33 }
34
35 #[test]
36 fn as_u16_round_trips() {
37 assert_eq!(FieldId::new(7).as_u16(), 7);
38 }
39}