Function format_debug_escape_into

Source
pub fn format_debug_escape_into<W, T>(dest: W, message: T) -> Result
where W: Write, T: AsRef<[u8]>,
Expand description

Write a UTF-8 debug representation of a byte slice into the given writer.

This method encodes a bytes slice into a UTF-8 valid representation by writing invalid sequences as hex escape codes (e.g. \x00) or C escape sequences (e.g. \a).

This method also escapes UTF-8 valid characters like \n and \t.

§Examples

Basic usage:


let mut message = String::from("cannot load such file -- ");
let filename = b"utf8-invalid-name-\xFF";
format_debug_escape_into(&mut message, filename);
assert_eq!(r"cannot load such file -- utf8-invalid-name-\xFF", message);

§Errors

This method only returns an error when the given writer returns an error.