Skip to content

Commit 9f8277e

Browse files
committed
Give contents their own lifetime
1 parent 7f96aae commit 9f8277e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

crates/ark/src/treesitter.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,11 +674,11 @@ impl<'ts_query> TsQuery<'ts_query> {
674674
}
675675

676676
/// Run the query on `contents` and collect all captures as (capture_name, node) pairs
677-
pub(crate) fn all_captures<'tree, 'query>(
677+
pub(crate) fn all_captures<'tree, 'query, 'contents>(
678678
&'query mut self,
679679
node: tree_sitter::Node<'tree>,
680-
contents: &'query [u8],
681-
) -> AllCaptures<'tree, 'query>
680+
contents: &'contents [u8],
681+
) -> AllCaptures<'tree, 'query, 'contents>
682682
where
683683
'tree: 'query,
684684
{
@@ -739,16 +739,16 @@ impl<'ts_query> TsQuery<'ts_query> {
739739
}
740740
}
741741

742-
pub(crate) struct AllCaptures<'tree, 'query> {
742+
pub(crate) struct AllCaptures<'tree, 'query, 'contents> {
743743
query: &'query tree_sitter::Query,
744-
matches_iter: tree_sitter::QueryMatches<'query, 'tree, &'query [u8], &'query [u8]>,
744+
matches_iter: tree_sitter::QueryMatches<'query, 'tree, &'contents [u8], &'contents [u8]>,
745745
current_captures_iter: Option<std::slice::Iter<'query, tree_sitter::QueryCapture<'tree>>>,
746746
}
747747

748-
impl<'tree, 'query> AllCaptures<'tree, 'query> {
748+
impl<'tree, 'query, 'contents> AllCaptures<'tree, 'query, 'contents> {
749749
pub(crate) fn new(
750750
query: &'query tree_sitter::Query,
751-
matches_iter: tree_sitter::QueryMatches<'query, 'tree, &'query [u8], &'query [u8]>,
751+
matches_iter: tree_sitter::QueryMatches<'query, 'tree, &'contents [u8], &'contents [u8]>,
752752
) -> Self {
753753
Self {
754754
query,
@@ -758,7 +758,7 @@ impl<'tree, 'query> AllCaptures<'tree, 'query> {
758758
}
759759
}
760760

761-
impl<'tree, 'query> Iterator for AllCaptures<'tree, 'query> {
761+
impl<'tree, 'query, 'contents> Iterator for AllCaptures<'tree, 'query, 'contents> {
762762
type Item = (String, tree_sitter::Node<'tree>);
763763

764764
// The iterator yields `(capture_name, node)` pairs by walking through all query matches.

0 commit comments

Comments
 (0)