Struct combine::stream::PointerOffset
source · [−]Expand description
Newtype around a pointer offset into a slice stream (&[T]
/&str
).
Tuple Fields
0: usize
Implementations
sourceimpl<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
sourceimpl<T: ?Sized> Clone for PointerOffset<T>
impl<T: ?Sized> Clone for PointerOffset<T>
sourceimpl<T> Debug for PointerOffset<T> where
T: ?Sized,
impl<T> Debug for PointerOffset<T> where
T: ?Sized,
sourceimpl<T: ?Sized> Default for PointerOffset<T>
impl<T: ?Sized> Default for PointerOffset<T>
sourceimpl<T> Display for PointerOffset<T> where
T: ?Sized,
impl<T> Display for PointerOffset<T> where
T: ?Sized,
sourceimpl<T: ?Sized> Ord for PointerOffset<T>
impl<T: ?Sized> Ord for PointerOffset<T>
sourceimpl<T: ?Sized> PartialEq<PointerOffset<T>> for PointerOffset<T>
impl<T: ?Sized> PartialEq<PointerOffset<T>> for PointerOffset<T>
sourceimpl<T: ?Sized> PartialOrd<PointerOffset<T>> for PointerOffset<T>
impl<T: ?Sized> PartialOrd<PointerOffset<T>> for PointerOffset<T>
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl<T: ?Sized> Copy for PointerOffset<T>
impl<T: ?Sized> Eq for PointerOffset<T>
Auto Trait Implementations
impl<T: ?Sized> RefUnwindSafe for PointerOffset<T> where
T: RefUnwindSafe,
impl<T: ?Sized> Send for PointerOffset<T> where
T: Send,
impl<T: ?Sized> Sync for PointerOffset<T> where
T: Sync,
impl<T: ?Sized> Unpin for PointerOffset<T> where
T: Unpin,
impl<T: ?Sized> UnwindSafe for PointerOffset<T> where
T: UnwindSafe,
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<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)
🔬 This is a nightly-only experimental API. (
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more