rust/src/rustdoc/escape_pass.rs

19 lines
294 B
Rust
Raw Normal View History

2012-03-16 14:20:29 -05:00
#[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";
}