1
0
dust/src/value/function.rs

31 lines
743 B
Rust
Raw Normal View History

2023-08-22 15:40:50 +00:00
use std::fmt::{self, Display, Formatter};
use serde::{Deserialize, Serialize};
use crate::{EvaluatorTree, Identifier, Result, Statement, Value, VariableMap};
2023-08-22 15:40:50 +00:00
2023-09-30 21:52:37 +00:00
#[derive(Debug, Clone, Serialize, Deserialize, Eq, PartialEq, PartialOrd, Ord)]
pub struct Function {
2023-10-01 09:03:59 +00:00
identifiers: Vec<Identifier>,
2023-09-30 21:52:37 +00:00
statements: Vec<Statement>,
}
2023-08-22 15:40:50 +00:00
impl Function {
2023-10-01 09:03:59 +00:00
pub fn new(identifiers: Vec<Identifier>, statements: Vec<Statement>) -> Self {
2023-09-30 21:52:37 +00:00
Function {
identifiers,
statements,
}
2023-08-22 15:40:50 +00:00
}
}
2023-08-22 15:40:50 +00:00
impl Display for Function {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
2023-09-30 21:52:37 +00:00
write!(
f,
"function < {:?} > {{ {:?} }}",
self.identifiers, self.statements
)
2023-08-22 15:40:50 +00:00
}
}