diff options
Diffstat (limited to 'src/libsyntax/parse/lexer/mod.rs')
| -rw-r--r-- | src/libsyntax/parse/lexer/mod.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 4c15fae9feb..50c7258fe1c 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -244,7 +244,9 @@ impl<'a> StringReader<'a> { /// Calls `f` with a string slice of the source text spanning from `start` /// up to but excluding `self.last_pos`, meaning the slice does not include /// the character `self.curr`. - pub fn with_str_from<T>(&self, start: BytePos, f: |s: &str| -> T) -> T { + pub fn with_str_from<T, F>(&self, start: BytePos, f: F) -> T where + F: FnOnce(&str) -> T, + { self.with_str_from_to(start, self.last_pos, f) } @@ -264,7 +266,9 @@ impl<'a> StringReader<'a> { /// Calls `f` with a string slice of the source text spanning from `start` /// up to but excluding `end`. - fn with_str_from_to<T>(&self, start: BytePos, end: BytePos, f: |s: &str| -> T) -> T { + fn with_str_from_to<T, F>(&self, start: BytePos, end: BytePos, f: F) -> T where + F: FnOnce(&str) -> T, + { f(self.filemap.src.slice( self.byte_offset(start).to_uint(), self.byte_offset(end).to_uint())) |
