libstd: Implement StrBuf, a new string buffer type like Vec, and

port all code over to use it.
This commit is contained in:
Patrick Walton
2014-04-02 16:54:22 -07:00
committed by Huon Wilson
parent 7fbcb400f0
commit d8e45ea7c0
66 changed files with 990 additions and 931 deletions

View File

@@ -27,10 +27,11 @@ use print::pp;
use std::cast;
use std::char;
use std::str;
use std::io;
use std::io::{IoResult, MemWriter};
use std::io;
use std::rc::Rc;
use std::str;
use std::strbuf::StrBuf;
pub enum AnnNode<'a> {
NodeBlock(&'a ast::Block),
@@ -2156,10 +2157,10 @@ impl<'a> State<'a> {
match lit.node {
ast::LitStr(ref st, style) => self.print_string(st.get(), style),
ast::LitChar(ch) => {
let mut res = ~"'";
let mut res = StrBuf::from_str("'");
char::from_u32(ch).unwrap().escape_default(|c| res.push_char(c));
res.push_char('\'');
word(&mut self.s, res)
word(&mut self.s, res.into_owned())
}
ast::LitInt(i, t) => {
word(&mut self.s, format!("{}{}", i, ast_util::int_ty_to_str(t)))