Skip to content

Commit 7f4eb9a

Browse files
committed
Provide ::set_{byte,point}_range on both query iterators
1 parent 97dfee6 commit 7f4eb9a

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

lib/binding_rust/lib.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,6 @@ pub enum QueryErrorKind {
198198
Structure,
199199
}
200200

201-
trait TextCallback<'a> {
202-
fn call(&mut self, node: Node);
203-
fn next_chunk(&mut self) -> Option<&'a [u8]>;
204-
}
205-
206201
#[derive(Debug)]
207202
enum TextPredicate {
208203
CaptureEqString(u32, String, bool),
@@ -1836,14 +1831,6 @@ impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryMatches<'a, 'tree, T> {
18361831
}
18371832
}
18381833

1839-
impl<'a, 'tree, T: TextProvider<'a>> QueryCaptures<'a, 'tree, T> {
1840-
pub fn set_byte_range(&mut self, start: usize, end: usize) {
1841-
unsafe {
1842-
ffi::ts_query_cursor_set_byte_range(self.ptr, start as u32, end as u32);
1843-
}
1844-
}
1845-
}
1846-
18471834
impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryCaptures<'a, 'tree, T> {
18481835
type Item = (QueryMatch<'a, 'tree>, usize);
18491836

@@ -1876,6 +1863,34 @@ impl<'a, 'tree, T: TextProvider<'a>> Iterator for QueryCaptures<'a, 'tree, T> {
18761863
}
18771864
}
18781865

1866+
impl<'a, 'tree, T: TextProvider<'a>> QueryMatches<'a, 'tree, T> {
1867+
pub fn set_byte_range(&mut self, start: usize, end: usize) {
1868+
unsafe {
1869+
ffi::ts_query_cursor_set_byte_range(self.ptr, start as u32, end as u32);
1870+
}
1871+
}
1872+
1873+
pub fn set_point_range(&mut self, start: Point, end: Point) {
1874+
unsafe {
1875+
ffi::ts_query_cursor_set_point_range(self.ptr, start.into(), end.into());
1876+
}
1877+
}
1878+
}
1879+
1880+
impl<'a, 'tree, T: TextProvider<'a>> QueryCaptures<'a, 'tree, T> {
1881+
pub fn set_byte_range(&mut self, start: usize, end: usize) {
1882+
unsafe {
1883+
ffi::ts_query_cursor_set_byte_range(self.ptr, start as u32, end as u32);
1884+
}
1885+
}
1886+
1887+
pub fn set_point_range(&mut self, start: Point, end: Point) {
1888+
unsafe {
1889+
ffi::ts_query_cursor_set_point_range(self.ptr, start.into(), end.into());
1890+
}
1891+
}
1892+
}
1893+
18791894
impl<'cursor, 'tree> fmt::Debug for QueryMatch<'cursor, 'tree> {
18801895
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
18811896
write!(

0 commit comments

Comments
 (0)