pub struct PointerOffset(pub usize);
Expand description
Newtype around a pointer offset into a slice stream (&[T]
/&str
).
Tuple Fields§
§0: usize
Implementations§
Source§impl PointerOffset
impl PointerOffset
Sourcepub fn translate_position<T>(self, initial_string: &T) -> usizewhere
T: ?Sized,
pub fn translate_position<T>(self, initial_string: &T) -> usizewhere
T: ?Sized,
Converts the pointer-based position into an indexed position.
let text = "b";
let err = token('a').easy_parse(text).unwrap_err();
assert_eq!(err.position.0, text.as_ptr() as usize);
assert_eq!(err.map_position(|p| p.translate_position(text)).position, 0);
Trait Implementations§
Source§impl Clone for PointerOffset
impl Clone for PointerOffset
Source§fn clone(&self) -> PointerOffset
fn clone(&self) -> PointerOffset
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PointerOffset
impl Debug for PointerOffset
Source§impl Default for PointerOffset
impl Default for PointerOffset
Source§fn default() -> PointerOffset
fn default() -> PointerOffset
Returns the “default value” for a type. Read more
Source§impl Display for PointerOffset
impl Display for PointerOffset
Source§impl Ord for PointerOffset
impl Ord for PointerOffset
Source§fn cmp(&self, other: &PointerOffset) -> Ordering
fn cmp(&self, other: &PointerOffset) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PointerOffset
impl PartialEq for PointerOffset
Source§impl PartialOrd for PointerOffset
impl PartialOrd for PointerOffset
impl Copy for PointerOffset
impl Eq for PointerOffset
impl StructuralPartialEq for PointerOffset
Auto Trait Implementations§
impl Freeze for PointerOffset
impl RefUnwindSafe for PointerOffset
impl Send for PointerOffset
impl Sync for PointerOffset
impl Unpin for PointerOffset
impl UnwindSafe for PointerOffset
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more