[red-knot] Report line numbers in mdtest relative to the markdown file, not the test snippet (#13804)

Co-authored-by: Alex Waygood <alex.waygood@gmail.com>
Co-authored-by: Micha Reiser <micha@reiser.io>
Co-authored-by: Carl Meyer <carl@oddbird.net>
This commit is contained in:
aditya pillai 2024-10-22 03:42:40 -04:00 committed by GitHub
parent 9d102799f9
commit cd6c937194
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 130 additions and 53 deletions

View file

@ -394,6 +394,18 @@ impl OneIndexed {
None => Self::MIN,
}
}
/// Checked addition. Returns `None` if overflow occurred.
#[must_use]
pub fn checked_add(self, rhs: Self) -> Option<Self> {
self.0.checked_add(rhs.0.get()).map(Self)
}
/// Checked subtraction. Returns `None` if overflow occurred.
#[must_use]
pub fn checked_sub(self, rhs: Self) -> Option<Self> {
self.0.get().checked_sub(rhs.get()).and_then(Self::new)
}
}
impl fmt::Display for OneIndexed {