From 8fe6fc11de4d6bfbffd8b961f5f1f24a338601d5 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 28 Jun 2013 14:04:13 -0700 Subject: Change char::escape_{default,unicode} to take callbacks instead of allocating strings --- src/libsyntax/parse/token.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/token.rs b/src/libsyntax/parse/token.rs index 94147825da4..a50fa416832 100644 --- a/src/libsyntax/parse/token.rs +++ b/src/libsyntax/parse/token.rs @@ -16,7 +16,6 @@ use util::interner::StrInterner; use util::interner; use std::cast; -use std::char; use std::cmp::Equiv; use std::local_data; use std::rand; @@ -166,7 +165,12 @@ pub fn to_str(in: @ident_interner, t: &Token) -> ~str { /* Literals */ LIT_INT(c, ast::ty_char) => { - ~"'" + char::escape_default(c as char) + "'" + let mut res = ~"'"; + do (c as char).escape_default |c| { + res.push_char(c); + } + res.push_char('\''); + res } LIT_INT(i, t) => { i.to_str() + ast_util::int_ty_to_str(t) -- cgit 1.4.1-3-g733a5