Make Node text methods take bytes
This commit is contained in:
parent
dcd4953498
commit
8db1b488e4
1 changed files with 3 additions and 3 deletions
|
|
@ -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> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue