remove_span_overlaps_idx

Function remove_span_overlaps_idx 

Source
pub fn remove_span_overlaps_idx(spans: &[Span]) -> Vec<usize>
Expand description

Remove overlapping spans from given spans, and returns remained span indices. First, longest spans are remained - if the two spans are overlapped, the first span will be remained. If the two spans are overlapped and their start positions are same, the longer span will be remained.

ยงExample

use textspan::remove_span_overlaps_idx;
let spans = [(0, 2), (0, 3), (2, 4), (5, 7)];
let ret = remove_span_overlaps_idx(&spans);
assert_eq!(ret, [1, 3]);