Byte literal not escaped when pushed onto String

Problem

The escaping backslash in the byte literal for apostrophe b'\'' is not removed when used in a String.

Example

O'Brien becomes O\'Brien


Here are some code snippets to show it...

let apos = vec![39];
print!("{:?}",String::from_utf8(apos).unwrap());

prints out "\'"

let apos: char = '\'';
let mut s = String::new();
s.push(apos);
print!("{:?}",s);	

prints out "\'"

let apos: char = '\'';
print!("byte literal is {:?} and u8 is {:?}",b'\'', apos as u8);

prints out byte literal is 39 and u8 is 39


Question

How can remove the escaping backslash when pushing the char onto a String, so that O'Brien remains O'Brien?

Try using the Display output (ie {}) format instead of Debug (ie {:?})

thank you very much. You are correct. I was using Debug in my tests so they kept failing. Display works.