]> git.lizzy.rs Git - rust.git/blobdiff - src/libsyntax/print/pprust.rs
libstd: Implement `StrBuf`, a new string buffer type like `Vec`, and
[rust.git] / src / libsyntax / print / pprust.rs
index 44e95aa9573c07909224bf7c91dc0f42fe837c77..0d8cd02fc7affd9fcdbfbd33824e489244ef558d 100644 (file)
 
 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 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
         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)))