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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 1 deletions

View File

@ -21,7 +21,7 @@ pub fn compute_between_dataframes(
if let (UntaggedValue::DataFrame(lhs), UntaggedValue::DataFrame(rhs)) = if let (UntaggedValue::DataFrame(lhs), UntaggedValue::DataFrame(rhs)) =
(&left.value, &right.value) (&left.value, &right.value)
{ {
let operation_span = left.tag.span.until(right.tag.span); let operation_span = right.tag.span.merge(left.tag.span);
match (lhs.is_series(), rhs.is_series()) { match (lhs.is_series(), rhs.is_series()) {
(true, true) => { (true, true) => {
let lhs = &lhs let lhs = &lhs

View File

@ -605,6 +605,16 @@ impl Span {
Span::new(self.start, other.end) 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. /// Returns a new Span by merging a later Span with the current Span.
/// ///
/// If the given Span is of the None variant, /// If the given Span is of the None variant,