use std::cmp::max instead of manual calculation

This commit is contained in:
Lucas Holten 2024-01-11 11:34:25 +01:00
parent 36f7f65f87
commit b1e2bd2563
1 changed files with 3 additions and 7 deletions

View File

@ -405,16 +405,12 @@ impl GraphicalReportHandler {
// The snippets will overlap, so we create one Big Chunky Boi
let left_end = left.offset() + left.len();
let right_end = right.offset() + right.len();
let new_end = std::cmp::max(left_end, right_end);
let new_span = LabeledSpan::new(
left.label().map(String::from),
left.offset(),
if right_end >= left_end {
// Right end goes past left end
right_end - left.offset()
} else {
// right is contained inside left
left.len()
},
new_end - left.offset(),
);
// Check that the two contexts can be combined
if let Ok(new_conts) =