From 6cd2b8bd442c9aae018b8113f2bbdc79d245ed38 Mon Sep 17 00:00:00 2001 From: Alex Bethel Date: Sat, 27 Nov 2021 11:11:03 -0600 Subject: [PATCH] Avoid trailing comma in cart printout --- ablescript/src/variables.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ablescript/src/variables.rs b/ablescript/src/variables.rs index 99f79557..5ee99cb6 100644 --- a/ablescript/src/variables.rs +++ b/ablescript/src/variables.rs @@ -532,8 +532,14 @@ impl Display for Value { let mut cart_vec = c.iter().collect::>(); cart_vec.sort_by(|x, y| x.0.partial_cmp(y.0).unwrap_or(std::cmp::Ordering::Less)); - for (key, value) in cart_vec { - write!(f, "{} <= {}, ", value.borrow(), key)?; + for (idx, (key, value)) in cart_vec.into_iter().enumerate() { + write!( + f, + "{}{} <= {}", + if idx != 0 { ", " } else { "" }, + value.borrow(), + key + )?; } write!(f, "]")