diff options
| author | littleblack111 <littleblack11111@gmail.com> | 2025-10-08 16:30:01 +0800 |
|---|---|---|
| committer | littleblack111 <littleblack11111@gmail.com> | 2025-10-08 16:30:01 +0800 |
| commit | 92965a7b9d5cd9db35b52e60cdc3962a2d9cf947 (patch) | |
| tree | ee8f627920ce8319cf0e47f86c657a8f4b189fb9 | |
| parent | dac1ae7fbc73d44274fe77e4c74cdac9bb0d440e (diff) | |
ast: impl Display for DepthExprmain
| -rw-r--r-- | src/ast.rs | 16 |
1 files changed, 15 insertions, 1 deletions
@@ -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(); |
