pub fn unescape_backslashed_verbatim(string: &str) -> Cow<'_, String, str>
Expand description
Replaces \
followed by any Unicode char
in string
with that char
, as lazily as possible.
If \\
is found, this sequence is consumed at once and a single \
remains in the output.
ยงExample
use cervine::Cow;
use lazy_transform_str::unescape_backslashed_verbatim;
let input = r#"A \"quoted\" word\\!"#;
let output = unescape_backslashed_verbatim(input);
assert_eq!(output, Cow::Owned(r#"A "quoted" word\!"#.into()));
let output = unescape_backslashed_verbatim(&output);
assert_eq!(output, Cow::Owned(r#"A "quoted" word!"#.into()));