rust/src/rustdoc/escape_pass.rs
2012-03-16 12:20:29 -07:00

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";
}