croma-core 1.1.0

Library-first ABC to MusicXML exporter
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
use crate::{SourceText, Span};

pub(crate) fn span_of(source: &SourceText, needle: &str) -> Span {
    let start = source
        .as_str()
        .find(needle)
        .unwrap_or_else(|| panic!("expected source to contain {needle:?}"));
    Span::new(start, start + needle.len())
}

pub(crate) fn assert_span_text(source: &SourceText, span: Span, expected: &str) {
    assert_eq!(source.slice(span), Some(expected));
}