pub trait UserPosn:
Sized
+ Debug
+ Copy
+ Default
+ PartialEq
+ Eq
+ Hash {
// Provided methods
fn advance_cols(self, _num_bytes: usize, _num_chars: usize) -> Self { ... }
fn advance_line(self, _num_bytes: usize) -> Self { ... }
fn line(&self) -> usize { ... }
fn column(&self) -> usize { ... }
fn error_fmt(&self, fmt: &mut Formatter<'_>) -> Result<(), Error> { ... }
}Expand description
Trait for location within a stream
This base trait is used to enable tracking the position of a token parser within a stream in a manner that is useful for human-readable error messages
A simple implementation can be null, if the position is not critical for error messages for the token parser - for example, parsing a simple string in a test.
For a single file implementation see crate::LineColumn
Provided Methods§
Sourcefn advance_cols(self, _num_bytes: usize, _num_chars: usize) -> Self
fn advance_cols(self, _num_bytes: usize, _num_chars: usize) -> Self
Advance the state of the stream by a number of bytes and a number of characters; the characters are guaranteed to not be newlines
For character streams (where num_bytes is not the same as num_char) this must only be invoked to move on to a new UTF8 character boundary - hence num_bytes must be a (sum of) len_utf8 values for the text at byte offset of self.
Sourcefn advance_line(self, _num_bytes: usize) -> Self
fn advance_line(self, _num_bytes: usize) -> Self
Advance the state of the stream by a number of bytes and to the start of the next line
For character streams this must only be invoked to move on to a new UTF8 character boundary - hence num_bytes must be a (sum of) len_utf8 values for the text at byte offset of self, the last character of which is a newline
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.