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<PointerOffset> for PointerOffset
impl PartialEq<PointerOffset> 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<PointerOffset> for PointerOffset
impl PartialOrd<PointerOffset> 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 more