plux_rs/function/
arg.rs

1use std::fmt::Display;
2
3use serde::{Deserialize, Serialize};
4
5use crate::variable::VariableType;
6
7#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Serialize, Deserialize)]
8pub struct Arg {
9    pub name: String,
10    pub ty: VariableType,
11}
12
13impl Arg {
14    pub fn new<S: Into<String>>(name: S, ty: VariableType) -> Self {
15        Self {
16            name: name.into(),
17            ty,
18        }
19    }
20}
21
22impl Default for Arg {
23    fn default() -> Self {
24        Self {
25            name: "arg".to_string(),
26            ty: Default::default(),
27        }
28    }
29}
30
31impl Display for Arg {
32    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33        write!(f, "{}: {}", self.name, self.ty)
34    }
35}