From 97b4c68b6c54f10e5bcc8ca4b5acb36a340cdf55 Mon Sep 17 00:00:00 2001 From: elvis Date: Mon, 20 Oct 2025 22:35:45 +0200 Subject: [PATCH] Fixed formatting --- rsprocess/src/trace.rs | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/rsprocess/src/trace.rs b/rsprocess/src/trace.rs index 9cb6347..6c15af5 100644 --- a/rsprocess/src/trace.rs +++ b/rsprocess/src/trace.rs @@ -400,31 +400,38 @@ impl< Formatter::from(translator, &*self.products_elements) )?; + writeln!(f, "Trace:")?; + let mut elements = self.elements.iter().peekable(); let mut enabled_reactions = self.enabled_reactions.iter(); - writeln!(f, "Trace:")?; while let Some(el) = elements.next() { if let Some(r) = enabled_reactions.next() { + let reaction_string = format!("{}", Formatter::from(translator, r)); + let reaction_string = if reaction_string.is_empty() { + "( )" + } else { + &format!("({})", reaction_string) + }; if elements.peek().is_some() { writeln!( f, - "{}\n\t\t|\n{: ^17}\n\t\t|\n\t\tv", + "{}\n |\n{: ^18}\n |\n v", Formatter::from(translator, el), - format!("({})", Formatter::from(translator, r)), + reaction_string, )?; } else { writeln!( f, - "{}\n\t\t|\n{: ^17}\n\t\t|\n\t\t?", + "{}\n |\n{: ^18}\n |\n ?", Formatter::from(translator, el), - format!("({})", Formatter::from(translator, r)), + reaction_string, )?; } } else if elements.peek().is_some() { writeln!( f, - "{}\n\t\t|\n\t\t|\n\t\t|\n\t\tv", + "{}\n |\n |\n |\n v", Formatter::from(translator, el) )?; } else {