v_escape 0.19.0

The simd optimized escaping code with macro
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#![cfg(all(feature = "fmt", feature = "string"))]

use v_escape::escape;

escape! {
    '"' -> """,
    '<' -> "&lt;"
}

#[test]
fn test() {
    let s = "Hello,< world!\"";
    let escaped = escape_fmt(s).to_string();
    assert_eq!(escaped, "Hello,&lt; world!&quot;");
    let mut escaped = String::with_capacity(s.len());
    escape_string(&s, &mut escaped);
    assert_eq!(escaped, "Hello,&lt; world!&quot;");
}