19 lines
294 B
Rust
19 lines
294 B
Rust
#[doc = "Escapes text sequences"];
|
|
|
|
export mk_pass;
|
|
|
|
fn mk_pass() -> pass {
|
|
text_pass::mk_pass("escape", escape)
|
|
}
|
|
|
|
fn escape(s: str) -> str {
|
|
str::replace(s, "\\", "\\\\")
|
|
}
|
|
|
|
#[test]
|
|
fn should_escape_backslashes() {
|
|
let s = "\\n";
|
|
let r = escape(s);
|
|
assert r == "\\\\n";
|
|
}
|