1
0
dust/src/value/function.rs

39 lines
876 B
Rust
Raw Normal View History

2023-08-22 15:40:50 +00:00
use std::fmt::{self, Display, Formatter};
use serde::{Deserialize, Serialize};
2023-09-30 21:52:37 +00:00
use crate::{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 {
identifiers: Vec<String>,
statements: Vec<Statement>,
}
2023-08-22 15:40:50 +00:00
impl Function {
2023-09-30 21:52:37 +00:00
pub fn new(identifiers: Vec<String>, statements: Vec<Statement>) -> Self {
Function {
identifiers,
statements,
}
2023-08-22 15:40:50 +00:00
}
pub fn run(&self) -> Result<Value> {
2023-09-29 06:53:31 +00:00
todo!()
2023-08-22 15:40:50 +00:00
}
pub fn run_with_context(&self, context: &mut VariableMap) -> Result<Value> {
2023-09-29 06:53:31 +00:00
todo!()
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
}
}