Allow QueryCursor::matches' text_callback to return any AsRef<[u8]> (#488)

This commit is contained in:
Tuấn-Anh Nguyễn 2019-11-18 01:40:06 +07:00 committed by Max Brunsfeld
parent ce633a85c6
commit 8e6220a0c5

View file

@ -1387,11 +1387,11 @@ impl QueryCursor {
/// Each match contains the index of the pattern that matched, and a list of captures.
/// Because multiple patterns can match the same set of nodes, one match may contain
/// captures that appear *before* some of the captures from a previous match.
pub fn matches<'a>(
pub fn matches<'a, T: AsRef<[u8]>>(
&mut self,
query: &'a Query,
node: Node<'a>,
mut text_callback: impl FnMut(Node<'a>) -> &[u8] + 'a,
mut text_callback: impl FnMut(Node<'a>) -> T + 'a,
) -> impl Iterator<Item = QueryMatch<'a>> + 'a {
let ptr = self.0.as_ptr();
unsafe { ffi::ts_query_cursor_exec(ptr, query.ptr.as_ptr(), node.0) };