diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2014-12-08 13:28:32 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2014-12-13 17:03:47 -0500 |
| commit | 0dac05dd627612232403c07ca8bd6d3376eec64a (patch) | |
| tree | 656a23a7314866c8fa5cc6ca787111db41d90834 /src/libsyntax/print/pprust.rs | |
| parent | 2160427900ea675e494274d42a8d8485724f440e (diff) | |
| download | rust-0dac05dd627612232403c07ca8bd6d3376eec64a.tar.gz rust-0dac05dd627612232403c07ca8bd6d3376eec64a.zip | |
libsyntax: use unboxed closures
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 26373d00aaf..6d8b8dcb8ba 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -165,7 +165,9 @@ impl<'a> State<'a> { } } -pub fn to_string(f: |&mut State| -> IoResult<()>) -> String { +pub fn to_string<F>(f: F) -> String where + F: FnOnce(&mut State) -> IoResult<()>, +{ use std::raw::TraitObject; let mut s = rust_printer(box Vec::new()); f(&mut s).unwrap(); @@ -426,8 +428,10 @@ pub mod with_hygiene { // This function is the trick that all the rest of the routines // hang on. - pub fn to_string_hyg(f: |&mut super::State| -> IoResult<()>) -> String { - super::to_string(|s| { + pub fn to_string_hyg<F>(f: F) -> String where + F: FnOnce(&mut super::State) -> IoResult<()>, + { + super::to_string(move |s| { s.encode_idents_with_hygiene = true; f(s) }) @@ -580,9 +584,9 @@ impl<'a> State<'a> { word(&mut self.s, "*/") } - pub fn commasep<T>(&mut self, b: Breaks, elts: &[T], - op: |&mut State, &T| -> IoResult<()>) - -> IoResult<()> { + pub fn commasep<T, F>(&mut self, b: Breaks, elts: &[T], mut op: F) -> IoResult<()> where + F: FnMut(&mut State, &T) -> IoResult<()>, + { try!(self.rbox(0u, b)); let mut first = true; for elt in elts.iter() { @@ -593,12 +597,14 @@ impl<'a> State<'a> { } - pub fn commasep_cmnt<T>( - &mut self, - b: Breaks, - elts: &[T], - op: |&mut State, &T| -> IoResult<()>, - get_span: |&T| -> codemap::Span) -> IoResult<()> { + pub fn commasep_cmnt<T, F, G>(&mut self, + b: Breaks, + elts: &[T], + mut op: F, + mut get_span: G) -> IoResult<()> where + F: FnMut(&mut State, &T) -> IoResult<()>, + G: FnMut(&T) -> codemap::Span, + { try!(self.rbox(0u, b)); let len = elts.len(); let mut i = 0u; |
