From 8db1b488e46d5bff2cb27f71812aa295eb796cb2 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Wed, 6 Feb 2019 19:42:47 -0800 Subject: [PATCH] Make Node text methods take bytes --- lib/binding/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/binding/lib.rs b/lib/binding/lib.rs index efc00978..138f73d1 100644 --- a/lib/binding/lib.rs +++ b/lib/binding/lib.rs @@ -535,12 +535,12 @@ impl<'tree> Node<'tree> { result } - pub fn utf8_text<'a>(&self, source: &'a str) -> Result<&'a str, str::Utf8Error> { - str::from_utf8(&source.as_bytes()[self.start_byte()..self.end_byte()]) + pub fn utf8_text<'a>(&self, source: &'a [u8]) -> Result<&'a str, str::Utf8Error> { + str::from_utf8(&source[self.start_byte()..self.end_byte()]) } pub fn utf16_text<'a>(&self, source: &'a [u16]) -> &'a [u16] { - &source[self.start_byte()..self.end_byte()] + &source.as_ref()[self.start_byte()..self.end_byte()] } pub fn walk(&self) -> TreeCursor<'tree> {