Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
CosmicHorrorDev committed Nov 20, 2024
1 parent ee9a90b commit f0df280
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions keyvalues-parser/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ impl ParseError {
self.inner
}

/// The span indicating where the error is in the original text
///
/// # Example
///
/// ```
/// # use keyvalues_parser::Vdf;
/// let vdf_text = "key value >:V extra bytes";
/// let err = Vdf::parse(vdf_text).unwrap_err();
/// let error_snippet = err.index_span().slice(vdf_text);
/// assert_eq!(error_snippet, ">:V extra bytes");
/// ```
pub fn index_span(&self) -> Span<usize> {
self.index_span.clone()
}
Expand Down

0 comments on commit f0df280

Please sign in to comment.