rust/src/librustdoc/escape_pass.rs

19 lines
293 B
Rust
Raw Normal View History

//! Escapes text sequences
2012-03-16 14:20:29 -05:00
export mk_pass;
2012-09-18 18:48:40 -05:00
fn mk_pass() -> Pass {
text_pass::mk_pass(~"escape", escape)
2012-03-16 14:20:29 -05:00
}
fn escape(s: ~str) -> ~str {
str::replace(s, ~"\\", ~"\\\\")
2012-03-16 14:20:29 -05:00
}
#[test]
fn should_escape_backslashes() {
let s = ~"\\n";
2012-03-16 14:20:29 -05:00
let r = escape(s);
assert r == ~"\\\\n";
2012-03-16 14:20:29 -05:00
}