Struct nom_supreme::final_parser::Location
source · [−]Expand description
A location in a string where an error may have occurred. In keeping with the typical practice from editors and other tools, line and columns are both 1-indexed.
Example
use nom_supreme::final_parser::{RecreateContext, Location};
let original_input = "Hello,\nWorld!\n";
let tail = &original_input[9..];
assert_eq!(
Location::recreate_context(original_input, tail),
Location { line: 2, column: 3 },
);
Fields
line: usize
The line number in the original input where the error occurred
column: usize
The column of the line in the original input where the error occurred
Implementations
sourceimpl Location
impl Location
sourcepub fn locate_tail<'a>(original_input: &'a str, tail: &'a str) -> Self
pub fn locate_tail<'a>(original_input: &'a str, tail: &'a str) -> Self
Given the original input string, as well as the context reported by nom, compute the location in the original string where the error occurred.
This function will report garbage (and may panic) if the context is not associated with the input
Trait Implementations
sourceimpl RecreateContext<&'_ str> for Location
impl RecreateContext<&'_ str> for Location
sourcefn recreate_context(original_input: &str, tail: &str) -> Self
fn recreate_context(original_input: &str, tail: &str) -> Self
Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
impl Copy for Location
impl Eq for Location
impl StructuralEq for Location
impl StructuralPartialEq for Location
Auto Trait Implementations
impl RefUnwindSafe for Location
impl Send for Location
impl Sync for Location
impl Unpin for Location
impl UnwindSafe for Location
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<I, T> ExtractContext<I, ()> for T
impl<I, T> ExtractContext<I, ()> for T
sourcefn extract_context(self, _original_input: I)
fn extract_context(self, _original_input: I)
Given the context attached to a nom error, and given the original input to the nom parser, extract more the useful context information. Read more
sourceimpl<T> Indentable for T where
T: Display,
impl<T> Indentable for T where
T: Display,
sourcefn indented_skip_initial(self, indent: &str) -> IndentedSkipIntial<'_, Self>
fn indented_skip_initial(self, indent: &str) -> IndentedSkipIntial<'_, Self>
sourceimpl<I> RecreateContext<I> for I
impl<I> RecreateContext<I> for I
sourcefn recreate_context(_original_input: I, tail: I) -> I
fn recreate_context(_original_input: I, tail: I) -> I
Given the original input, as well as the context reported by nom, recreate a context in the original string where the error occurred. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more