From 8e8bdf291c753d17aafe36fb2fda20e83a60f2d6 Mon Sep 17 00:00:00 2001 From: Yaroslav Bolyukin Date: Sun, 23 May 2021 15:46:19 +0000 Subject: [PATCH] feat: prettier AST printing --- --- a/crates/jrsonnet-parser/src/expr.rs +++ b/crates/jrsonnet-parser/src/expr.rs @@ -329,7 +329,15 @@ pub struct LocExpr(pub Rc, pub Option); impl Debug for LocExpr { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{:?} from {:?}", self.0, self.1) + if f.alternate() { + write!(f, "{:#?}", self.0)?; + } else { + write!(f, "{:?}", self.0)?; + } + if let Some(loc) = &self.1 { + write!(f, " from {:?}", loc)?; + } + Ok(()) } } -- gitstuff