[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:
@@ -26,6 +26,16 @@ impl<'a> Cursor<'a> {
|
||||
self.chars.clone()
|
||||
}
|
||||
|
||||
/// Returns the remaining input as byte slice.
|
||||
pub fn as_bytes(&self) -> &'a [u8] {
|
||||
self.as_str().as_bytes()
|
||||
}
|
||||
|
||||
/// Returns the remaining input as string slice.
|
||||
pub fn as_str(&self) -> &'a str {
|
||||
self.chars.as_str()
|
||||
}
|
||||
|
||||
/// Peeks the next character from the input stream without consuming it.
|
||||
/// Returns [`EOF_CHAR`] if the file is at the end of the file.
|
||||
pub fn first(&self) -> char {
|
||||
@@ -110,4 +120,13 @@ impl<'a> Cursor<'a> {
|
||||
self.bump_back();
|
||||
}
|
||||
}
|
||||
|
||||
/// Skips the next `count` bytes.
|
||||
///
|
||||
/// ## Panics
|
||||
/// - If `count` is larger than the remaining bytes in the input stream.
|
||||
/// - If `count` indexes into a multi-byte character.
|
||||
pub fn skip_bytes(&mut self, count: usize) {
|
||||
self.chars = self.chars.as_str()[count..].chars();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user