Skip to content

Commit

Permalink
Add indices to MatchRange (v1.12 feature)
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Jan 14, 2025
1 parent 40f9402 commit 730e9ed
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ use std::collections::HashMap;
pub struct MatchRange {
pub start: usize,
pub length: usize,

/// If the match is somewhere inside a (potentially nested) array, this
/// field is set to the index/indices of the matched element(s).
///
/// In the simple case, if the field has the value `["foo", "bar"]`, then
/// searching for `ba` will return `indices: Some([1])`. If the value
/// contains multiple nested arrays, the first index describes the most
/// top-level array, and descending from there. For example, if the value is
/// `[{ x: "cat" }, "bear", { y: ["dog", "fox"] }]`, searching for `dog`
/// will return `indices: Some([2, 0])`.
pub indices: Option<Vec<usize>>,
}

#[derive(Serialize, Debug, Eq, PartialEq, Clone)]
Expand Down

0 comments on commit 730e9ed

Please sign in to comment.