Skip to main content

find_spans_squeezed

Function find_spans_squeezed 

Source
pub fn find_spans_squeezed<S: AsRef<str>>(
    lines: &[S],
    block: &[String],
) -> Vec<(usize, usize)>
Expand description

Find every non-overlapping squeezed match of block in lines, scanning forward (see [align_squeezed]). Returns each match’s (0-based start, source-line count) span — the span can be longer than the block when the source has wider blank runs than the anchor.

§Examples

use coding_tools::block::find_spans_squeezed;

// The anchor's single blank line absorbs the source's two blank lines.
let lines = ["foo()", "", "", "bar()"];
let block = ["foo()".to_string(), String::new(), "bar()".to_string()];
assert_eq!(find_spans_squeezed(&lines, &block), vec![(0, 4)]);