summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-10-08 16:30:01 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-10-08 16:30:01 +0800
commit92965a7b9d5cd9db35b52e60cdc3962a2d9cf947 (patch)
treeee8f627920ce8319cf0e47f86c657a8f4b189fb9 /src/ast.rs
parentdac1ae7fbc73d44274fe77e4c74cdac9bb0d440e (diff)
ast: impl Display for DepthExprmain
Diffstat (limited to 'src/ast.rs')
-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();