From 0ca09b9b1a2111f53702c71b47e46c8ffbcf185a Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 19 Jan 2023 18:56:13 -0800 Subject: [PATCH] Improve formatting of single quote in Debug of CxxString --- src/lossy.rs | 2 +- tests/cxx_string.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lossy.rs b/src/lossy.rs index d68a2e7b..8ccf0f93 100644 --- a/src/lossy.rs +++ b/src/lossy.rs @@ -37,7 +37,7 @@ pub fn debug(mut bytes: &[u8], f: &mut fmt::Formatter) -> fmt::Result { let mut written = 0; for (i, ch) in valid.char_indices() { let esc = ch.escape_debug(); - if esc.len() != 1 { + if esc.len() != 1 && ch != '\'' { f.write_str(&valid[written..i])?; for ch in esc { f.write_char(ch)?; diff --git a/tests/cxx_string.rs b/tests/cxx_string.rs index 6925e278..67444fa5 100644 --- a/tests/cxx_string.rs +++ b/tests/cxx_string.rs @@ -18,5 +18,5 @@ fn test_async_cxx_string() { fn test_debug() { let_cxx_string!(s = "x\"y\'z"); - assert_eq!(format!("{:?}", s), r#""x\"y\'z""#); + assert_eq!(format!("{:?}", s), r#""x\"y'z""#); }