From 92965a7b9d5cd9db35b52e60cdc3962a2d9cf947 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Wed, 8 Oct 2025 16:30:01 +0800 Subject: ast: impl Display for DepthExpr --- src/ast.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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>) -> Vec> { let mut exprs: Vec> = Vec::new(); -- cgit v1.2.3