pub struct PointerOffset<T: ?Sized>(pub usize, _);
Expand description
Newtype around a pointer offset into a slice stream (&[T]
/&str
).
Tuple Fields§
§0: usize
Implementations§
source§impl<T> PointerOffset<T>where
T: ?Sized,
impl<T> PointerOffset<T>where
T: ?Sized,
pub fn new(offset: usize) -> Self
sourcepub fn translate_position(self, initial_slice: &T) -> usize
pub fn translate_position(self, initial_slice: &T) -> usize
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<T: ?Sized> Clone for PointerOffset<T>
impl<T: ?Sized> Clone for PointerOffset<T>
source§impl<T> Debug for PointerOffset<T>where
T: ?Sized,
impl<T> Debug for PointerOffset<T>where
T: ?Sized,
source§impl<T: ?Sized> Default for PointerOffset<T>
impl<T: ?Sized> Default for PointerOffset<T>
source§impl<T> Display for PointerOffset<T>where
T: ?Sized,
impl<T> Display for PointerOffset<T>where
T: ?Sized,
source§impl<T: ?Sized> Ord for PointerOffset<T>
impl<T: ?Sized> Ord for PointerOffset<T>
source§impl<T: ?Sized> PartialEq for PointerOffset<T>
impl<T: ?Sized> PartialEq for PointerOffset<T>
source§impl<T: ?Sized> PartialOrd for PointerOffset<T>
impl<T: ?Sized> PartialOrd for PointerOffset<T>
impl<T: ?Sized> Copy for PointerOffset<T>
impl<T: ?Sized> Eq for PointerOffset<T>
Auto Trait Implementations§
impl<T> Freeze for PointerOffset<T>where
T: ?Sized,
impl<T> RefUnwindSafe for PointerOffset<T>where
T: RefUnwindSafe + ?Sized,
impl<T> Send for PointerOffset<T>
impl<T> Sync for PointerOffset<T>
impl<T> Unpin for PointerOffset<T>
impl<T> UnwindSafe for PointerOffset<T>where
T: UnwindSafe + ?Sized,
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)