Struct combine::stream::PointerOffset
source · 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§fn eq(&self, other: &PointerOffset) -> bool
fn eq(&self, other: &PointerOffset) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for PointerOffset
impl PartialOrd for PointerOffset
source§fn partial_cmp(&self, other: &PointerOffset) -> Option<Ordering>
fn partial_cmp(&self, other: &PointerOffset) -> Option<Ordering>
1.0.0 · source§fn 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 moreimpl Copy for PointerOffset
impl Eq for PointerOffset
impl StructuralEq for PointerOffset
impl StructuralPartialEq for PointerOffset
Auto Trait Implementations§
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