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

@@ -8,14 +8,15 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::char;
use ast;
use codemap;
use ext::base;
use ext::build::AstBuilder;
use parse::token;
use std::char;
use std::strbuf::StrBuf;
pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
sp: codemap::Span,
tts: &[ast::TokenTree]) -> base::MacResult {
@@ -23,7 +24,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
Some(e) => e,
None => return base::MacResult::dummy_expr(sp)
};
let mut accumulator = ~"";
let mut accumulator = StrBuf::new();
for e in es.move_iter() {
match e.node {
ast::ExprLit(lit) => {
@@ -56,5 +57,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
}
}
}
base::MRExpr(cx.expr_str(sp, token::intern_and_get_ident(accumulator)))
base::MRExpr(cx.expr_str(
sp,
token::intern_and_get_ident(accumulator.into_owned())))
}