rust/src/librustdoc/escape_pass.rs

17 lines
280 B
Rust
Raw Normal View History

//! Escapes text sequences
2012-03-16 14:20:29 -05:00
2012-11-19 20:00:12 -06:00
pub 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
}