1
Fork 0

auto merge of #13440 : huonw/rust/strbuf, r=alexcrichton

libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and port all code over to use it.

Rebased & tests-fixed version of https://github.com/mozilla/rust/pull/13269
This commit is contained in:
bors 2014-04-10 21:01:41 -07:00
commit cea8def620
66 changed files with 1070 additions and 983 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)))