Improve formatting of single quote in Debug of CxxString

This commit is contained in:
David Tolnay 2023-01-19 18:56:13 -08:00
parent 759a9dddda
commit 0ca09b9b1a
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 2 additions and 2 deletions

View File

@ -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)?;

View File

@ -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""#);
}