summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast.rs16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/ast.rs b/src/ast.rs
index fb648e0..d9aa699 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -1,5 +1,5 @@
use crate::tokenizer::If;
-use std::iter::Peekable;
+use std::{fmt::Display, iter::Peekable};
use crate::parser::{Expr, ExprT, Metadata, Scope};
@@ -15,6 +15,20 @@ pub enum DepthExpr<'a> {
Process(&'a str),
}
+impl<'a> Display for DepthExpr<'a> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ write!(
+ f,
+ "{}",
+ match self {
+ DepthExpr::IO(s) => s.to_string(),
+ DepthExpr::Process(s) => s.to_string(),
+ _ => panic!("Cannot convert complex field to string"),
+ }
+ )
+ }
+}
+
pub fn parse<'a>(vec: &Vec<Expr<'a>>) -> Vec<DepthExpr<'a>> {
let mut exprs: Vec<DepthExpr<'a>> = Vec::new();