Add a b"xx" byte string literal of type &'static [u8].

This commit is contained in:
Simon Sapin
2014-06-07 15:32:01 +01:00
parent bccdba0296
commit d7e01b5809
12 changed files with 185 additions and 70 deletions

View File

@@ -2342,19 +2342,9 @@ impl<'a> State<'a> {
ast::LitBool(val) => {
if val { word(&mut self.s, "true") } else { word(&mut self.s, "false") }
}
ast::LitBinary(ref arr) => {
try!(self.ibox(indent_unit));
try!(word(&mut self.s, "["));
try!(self.commasep_cmnt(Inconsistent,
arr.as_slice(),
|s, u| {
word(&mut s.s,
format!("{}",
*u).as_slice())
},
|_| lit.span));
try!(word(&mut self.s, "]"));
self.end()
ast::LitBinary(ref v) => {
let escaped: String = v.iter().map(|&b| b as char).collect();
word(&mut self.s, format!("b\"{}\"", escaped.escape_default()).as_slice())
}
}
}