1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use core::ops::{Add, Sub};
use derive_more::{Deref, From};
#[repr(transparent)]
#[derive(Debug, Clone, Copy, Default, Eq, Hash, Ord, PartialEq, PartialOrd, From, Deref, packable::Packable)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct MilestoneIndex(pub u32);
impl MilestoneIndex {
pub fn new(value: u32) -> Self {
Self(value)
}
}
impl core::fmt::Display for MilestoneIndex {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self.0)
}
}
impl Add for MilestoneIndex {
type Output = Self;
fn add(self, other: Self) -> Self {
Self(*self + *other)
}
}
impl Add<u32> for MilestoneIndex {
type Output = Self;
fn add(self, other: u32) -> Self {
Self(*self + other)
}
}
impl Sub for MilestoneIndex {
type Output = Self;
fn sub(self, other: Self) -> Self {
Self(*self - *other)
}
}
impl Sub<u32> for MilestoneIndex {
type Output = Self;
fn sub(self, other: u32) -> Self {
Self(*self - other)
}
}