escape_str

Function escape_str 

Source
pub fn escape_str(input: &str) -> Escape<'_> 
Expand description

Creates a streaming JSON string escaper from a string slice.

The returned Escape iterator lazily processes the input string, yielding slices that represent the escaped output.

§Examples

use json_escape::escape_str;

let escaper = escape_str("a\nb");
let escaped_parts: Vec<_> = escaper.collect();

assert_eq!(escaped_parts, vec!["a", r#"\n"#, "b"]);