1use std::{fmt, ops::Deref};
4
5#[derive(Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
7pub struct ArgNo(usize);
8
9impl From<usize> for ArgNo {
10 fn from(value: usize) -> Self {
11 Self(value)
12 }
13}
14
15impl Deref for ArgNo {
16 type Target = usize;
17
18 fn deref(&self) -> &Self::Target {
19 &self.0
20 }
21}
22
23impl ArgNo {
24 pub fn offset_by(self, offset: usize) -> Self {
26 Self(self.0 + offset)
27 }
28}
29
30impl fmt::Display for ArgNo {
31 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
32 write!(f, "{}", self.0)
33 }
34}
35
36impl fmt::Debug for ArgNo {
37 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
38 write!(f, "arg{}", self.0)
39 }
40}