Merge branch 'master' into node-fields

This commit is contained in:
Max Brunsfeld 2019-02-14 09:35:47 -08:00
commit 4f069fbe3b
9 changed files with 40 additions and 37 deletions

View file

@ -259,7 +259,8 @@ impl Parser {
pub fn parse(&mut self, input: impl AsRef<[u8]>, old_tree: Option<&Tree>) -> Option<Tree> {
let bytes = input.as_ref();
self.parse_with(&mut |i, _| &bytes[i..], old_tree)
let len = bytes.len();
self.parse_with(&mut |i, _| if i < len { &bytes[i..] } else { &[] }, old_tree)
}
pub fn parse_utf16(
@ -268,7 +269,8 @@ impl Parser {
old_tree: Option<&Tree>,
) -> Option<Tree> {
let code_points = input.as_ref();
self.parse_utf16_with(&mut |i, _| &code_points[i..], old_tree)
let len = code_points.len();
self.parse_utf16_with(&mut |i, _| if i < len { &code_points[i..] } else { &[] }, old_tree)
}
pub fn parse_with<'a, T: FnMut(usize, Point) -> &'a [u8]>(