diff --git a/lib/binding_rust/lib.rs b/lib/binding_rust/lib.rs index 2cf5898e..d187c965 100644 --- a/lib/binding_rust/lib.rs +++ b/lib/binding_rust/lib.rs @@ -1512,6 +1512,14 @@ impl Query { &self.capture_names } + /// Get the index for a given capture name. + pub fn capture_index_for_name(&self, name: &str) -> Option { + self.capture_names + .iter() + .position(|n| n == name) + .map(|ix| ix as u32) + } + /// Get the properties that are checked for the given pattern index. /// /// This includes predicates with the operators `is?` and `is-not?`.