merge span (#4031)

This commit is contained in:
Fernando Herrera
2021-09-22 20:48:05 +01:00
committed by GitHub
parent 59697cab63
commit 962b258cc6
2 changed files with 11 additions and 1 deletions

View File

@ -605,6 +605,16 @@ impl Span {
Span::new(self.start, other.end)
}
pub fn merge(&self, other: impl Into<Span>) -> Span {
let other = other.into();
if other.end < self.start {
other.until(self)
} else {
self.until(other)
}
}
/// Returns a new Span by merging a later Span with the current Span.
///
/// If the given Span is of the None variant,