1#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
10pub struct Uid(u64);
11
12impl Uid {
13 #[must_use]
23 pub const fn get(self) -> u64 {
24 self.0
25 }
26}
27
28impl From<u64> for Uid {
29 fn from(value: u64) -> Self {
30 Self(value)
31 }
32}
33
34impl From<Uid> for u64 {
35 fn from(uid: Uid) -> Self {
36 uid.0
37 }
38}
39
40#[cfg(test)]
41mod tests {
42 use super::*;
43
44 #[test]
45 fn conversions_round_trip() {
46 let uid = Uid::from(u64::MAX);
47 assert_eq!(uid.get(), u64::MAX);
48 assert_eq!(u64::from(uid), u64::MAX);
49 assert_eq!(Uid::from(0).get(), 0);
50 }
51
52 #[test]
53 fn ordering_and_equality_follow_the_value() {
54 assert!(Uid::from(1) < Uid::from(2));
55 assert_eq!(Uid::from(7), Uid::from(7));
56 assert_ne!(Uid::from(7), Uid::from(8));
57 }
58}