Files
nix-js/nix-js/src/ir/span_utils.rs
2026-01-24 11:20:12 +08:00

19 lines
477 B
Rust

#![allow(unused)]
use rnix::TextRange;
pub fn merge_spans(spans: impl IntoIterator<Item = TextRange>) -> TextRange {
let mut spans = spans.into_iter();
let first = spans.next().unwrap_or_else(synthetic_span);
spans.fold(first, |acc, span| {
let start = acc.start().min(span.start());
let end = acc.end().max(span.end());
TextRange::new(start, end)
})
}
pub fn synthetic_span() -> TextRange {
TextRange::new(0.into(), 0.into())
}