Skip to content

Commit

Permalink
document Offset (#1752)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed May 5, 2024
1 parent 82b09f0 commit dff6cdc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ where
}

/// Transforms a `VerboseError` into a trace with input position information
///
/// The errors contain references to input data that must come from `input`,
/// because nom calculates byte offsets between them
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "docsrs", doc(cfg(feature = "alloc")))]
pub fn convert_error<I: core::ops::Deref<Target = str>>(
Expand Down
2 changes: 2 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ impl<'a> Input for &'a str {
/// Useful functions to calculate the offset between slices and show a hexdump of a slice
pub trait Offset {
/// Offset between the first byte of self and the first byte of the argument
/// the argument must be a part of self, otherwise this can fail with arithmetic
/// underflows as it compares byte offsets
fn offset(&self, second: &Self) -> usize;
}

Expand Down

0 comments on commit dff6cdc

Please sign in to comment.