Struct pest::inputs::Span
[−]
[src]
pub struct Span<I: Input> { /* fields omitted */ }
A struct of a span over an Input. It is created from either
two Positions or from a
Pair.
Methods
impl<I: Input> Span<I>[src]
fn start(&self) -> usize
Returns the Span's start position.
Examples
let input = Rc::new(StringInput::new("ab".to_owned())); let start = Position::from_start(input); let end = start.clone().match_string("ab").unwrap(); let span = start.span(end); assert_eq!(span.start(), 0);
fn end(&self) -> usize
Returns the Span's end position.
Examples
let input = Rc::new(StringInput::new("ab".to_owned())); let start = Position::from_start(input); let end = start.clone().match_string("ab").unwrap(); let span = start.span(end); assert_eq!(span.end(), 2);
fn split(self) -> (Position<I>, Position<I>)
Splits the Span into a pair of Positions.
Examples
let input = Rc::new(StringInput::new("ab".to_owned())); let start = Position::from_start(input); let end = start.clone().match_string("ab").unwrap(); let span = start.clone().span(end.clone()); assert_eq!(span.split(), (start, end));
fn as_str(&self) -> &str
Captures a &str slice from the Input defined by the Span.
Examples
let input = Rc::new(StringInput::new("abc".to_owned())); let start = Position::from_start(input).skip(1).unwrap(); let end = start.clone().match_string("b").unwrap(); let span = start.span(end); assert_eq!(span.as_str(), "b");
Trait Implementations
impl<I: Input> Debug for Span<I>[src]
impl<I: Input> Clone for Span<I>[src]
fn clone(&self) -> Span<I>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0
Performs copy-assignment from source. Read more
impl<I: Input> PartialEq for Span<I>[src]
fn eq(&self, other: &Span<I>) -> bool
This method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Rhs) -> bool1.0.0
This method tests for !=.
impl<I: Input> Eq for Span<I>[src]
impl<I: Input> PartialOrd for Span<I>[src]
fn partial_cmp(&self, other: &Span<I>) -> Option<Ordering>
This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool1.0.0
This method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Rhs) -> bool1.0.0
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Rhs) -> bool1.0.0
This method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Rhs) -> bool1.0.0
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl<I: Input> Ord for Span<I>[src]
fn cmp(&self, other: &Span<I>) -> Ordering
This method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self
ord_max_min)Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
ord_max_min)Compares and returns the minimum of two values. Read more