From 2059589f5420bed3d490822fc9560db3c3a21515 Mon Sep 17 00:00:00 2001 From: Matti Niemenmaa Date: Mon, 1 Oct 2018 11:58:57 +0300 Subject: Avoid panic on pretty string ending in single quote Fixes #262. --- src/ser.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/ser.rs b/src/ser.rs index 9d989db..9f36f59 100644 --- a/src/ser.rs +++ b/src/ser.rs @@ -585,6 +585,10 @@ impl<'a> Serializer<'a> { } } } + if can_be_pretty && found_singles > 0 && value.ends_with('\'') { + // We cannot escape the ending quote so we must use """ + can_be_pretty = false; + } if !can_be_pretty { debug_assert!(ty != Type::OnelineTripple); return Repr::Std(ty); -- cgit v1.2.3