syntax: pass some values around by reference

This commit is contained in:
Erick Tryzelaar
2013-03-27 07:01:45 -07:00
parent 2f1ab3a7fa
commit bd77e9433f
2 changed files with 6 additions and 6 deletions

View File

@@ -88,7 +88,7 @@ pub mod rt {
} }
} }
impl ToSource for ~[@ast::item] { impl<'self> ToSource for &'self [@ast::item] {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~"\n\n") str::connect(self.map(|i| i.to_source(cx)), ~"\n\n")
} }
@@ -100,7 +100,7 @@ pub mod rt {
} }
} }
impl ToSource for ~[@ast::Ty] { impl<'self> ToSource for &'self [@ast::Ty] {
fn to_source(&self, cx: @ext_ctxt) -> ~str { fn to_source(&self, cx: @ext_ctxt) -> ~str {
str::connect(self.map(|i| i.to_source(cx)), ~", ") str::connect(self.map(|i| i.to_source(cx)), ~", ")
} }
@@ -216,7 +216,7 @@ pub mod rt {
} }
} }
impl ToTokens for ~[@ast::item] { impl<'self> ToTokens for &'self [@ast::item] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }
@@ -228,7 +228,7 @@ pub mod rt {
} }
} }
impl ToTokens for ~[@ast::Ty] { impl<'self> ToTokens for &'self [@ast::Ty] {
fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] { fn to_tokens(&self, cx: @ext_ctxt) -> ~[token_tree] {
cx.parse_tts(self.to_source(cx)) cx.parse_tts(self.to_source(cx))
} }

View File

@@ -324,7 +324,7 @@ pub fn commasep<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN)) {
pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN), pub fn commasep_cmnt<IN>(s: @ps, b: breaks, elts: &[IN], op: &fn(@ps, IN),
get_span: &fn(IN) -> codemap::span) { get_span: &fn(IN) -> codemap::span) {
box(s, 0u, b); box(s, 0u, b);
let len = vec::len::<IN>(elts); let len = elts.len();
let mut i = 0u; let mut i = 0u;
for elts.each |elt| { for elts.each |elt| {
maybe_print_comment(s, get_span(*elt).hi); maybe_print_comment(s, get_span(*elt).hi);
@@ -2133,7 +2133,7 @@ pub fn print_comment(s: @ps, cmnt: comments::cmnt) {
} }
} }
pub fn print_string(s: @ps, st: ~str) { pub fn print_string(s: @ps, st: &str) {
word(s.s, ~"\""); word(s.s, ~"\"");
word(s.s, str::escape_default(st)); word(s.s, str::escape_default(st));
word(s.s, ~"\""); word(s.s, ~"\"");