Allow empty span slice for now (#529)

This commit is contained in:
JT 2021-12-20 06:25:02 +11:00 committed by GitHub
parent c37bdcd119
commit cf5048205f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -48,11 +48,13 @@ impl Span {
}
}
/// Used when you have a slice of spans of at least size 1
pub fn span(spans: &[Span]) -> Span {
let length = spans.len();
if length == 0 {
panic!("Internal error: tried to create a 0-length span")
// TODO: do this for now, but we might also want to protect against this case
Span { start: 0, end: 0 }
} else if length == 1 {
spans[0]
} else {