Struct PairsHelper

Source
pub struct PairsHelper<'i, Rule: RuleType>(pub Pairs<'i, Rule>);
Expand description

A useful wrapper around pest Pairs, that provide several convenient shortcuts to read the Pair’s inside it.

It is intended to be used in exhaustive parsing, and will assert that all Pair’s have been read out when this wrapper is dropped.

Tuple Fields§

§0: Pairs<'i, Rule>

Implementations§

Source§

impl<'i, Rule: RuleType> PairsHelper<'i, Rule>

Source

pub fn next(&mut self) -> Pair<'i, Rule>

Get next Pair. Panics if there is not one.

Source

pub fn next_rule(&mut self, rule: Rule) -> Pair<'i, Rule>

Get next Pair and assert its rule type. Panics if there is not one, or the rule type does not match.

Source

pub fn next_rule_opt(&mut self, rule: Rule) -> Option<Pair<'i, Rule>>

Get the next Pair if it matches the given Rule. This will not panic.

Source

pub fn iter_while<'j>(&'j mut self, rule: Rule) -> PairPartialIter<'i, 'j, Rule>

Create an iterator of the first consecutive Pair’s that match a given Rule.

Trait Implementations§

Source§

impl<'i, Rule: RuleType> Drop for PairsHelper<'i, Rule>

Source§

fn drop(&mut self)

An error message will be printed when this PairsHelper is dropped.

We handled the “double panic” issue by not asserting when the drop is already initiated by another panic.

Auto Trait Implementations§

§

impl<'i, Rule> Freeze for PairsHelper<'i, Rule>

§

impl<'i, Rule> RefUnwindSafe for PairsHelper<'i, Rule>
where Rule: RefUnwindSafe,

§

impl<'i, Rule> !Send for PairsHelper<'i, Rule>

§

impl<'i, Rule> !Sync for PairsHelper<'i, Rule>

§

impl<'i, Rule> Unpin for PairsHelper<'i, Rule>

§

impl<'i, Rule> UnwindSafe for PairsHelper<'i, Rule>
where Rule: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.