Function textspan::align_spans_by_mapping [−][src]
pub fn align_spans_by_mapping<T: AsRef<[usize]>>(
spans: &[Span],
mapping: &[T]
) -> Vec<Vec<Span>>
Converts the spans by the given mapping.
Generally speaking, the character correspondence between two texts is not
necessarily surjective, not injective, not even a methematical map - some
character in textA may not have a correspondence in textB, or may have
multiple correspondences in textB. Thus, mapping should be provided as
Vec<Vec<Span>>.
Examples
let spans = [(0, 2), (3, 4)]; let mapping = [vec![0, 1], vec![], vec![2], vec![4, 5, 6]]; assert_eq!( textspan::align_spans_by_mapping(&spans, &mapping), [[(0, 2)], [(4, 7)]] )