continuity_buffer/
revision.rs1#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
10pub struct Revision(pub u64);
11
12impl Revision {
13 pub const INITIAL: Self = Self(0);
15
16 #[must_use]
18 pub const fn next(self) -> Self {
19 Self(self.0 + 1)
20 }
21
22 #[must_use]
24 pub const fn get(self) -> u64 {
25 self.0
26 }
27}
28
29#[cfg(test)]
30mod tests {
31 use super::*;
32
33 #[test]
34 fn next_increments_by_one() {
35 assert_eq!(Revision::INITIAL.next(), Revision(1));
36 assert_eq!(Revision(7).next(), Revision(8));
37 }
38
39 #[test]
40 fn ordering_is_numeric() {
41 assert!(Revision(0) < Revision(1));
42 assert!(Revision(99) > Revision(98));
43 }
44}