hdrepresentation/
arg.rs

1pub use crate::types::*;
2
3#[derive(Copy, Eq, Serialize, Deserialize, Debug, Clone, PartialEq)]
4pub struct Arg {
5    pub value: Option<i64>,
6    pub index: Option<usize>,
7    pub is_variable: bool,
8}
9
10impl Arg {
11    pub fn new(x: i64, is_variable: bool) -> Self {
12        if is_variable && x >= 0 {
13            Self {
14                value: None,
15                index: Some(x as usize),
16                is_variable: true,
17            }
18        } else {
19            Self {
20                value: Some(x),
21                index: None,
22                is_variable: false,
23            }
24        }
25    }
26}