[][src]Struct pahs::Progress

#[must_use]pub struct Progress<P, T, E> {
    pub pos: P,
    pub status: Result<T, E>,
}

Tracks the result of a parser: where it is and if it is successful.

On success, some value has been parsed. On failure, nothing has been parsed and the error indicates the reason for the failure. The returned point indicates where to next start parsing, often unchanged on failure.

Fields

pos: P

The current location.

status: Result<T, E>

If the point indicates the location of a successful or failed parse.

Implementations

impl<P, T, E> Progress<P, T, E>[src]

pub fn success(pos: P, val: T) -> Progress<P, T, E>[src]

Creates a new Progress value indicating a successful parse.

pub fn failure(pos: P, err: E) -> Progress<P, T, E>[src]

Creates a new Progress value indicating a failed parse.

pub fn map<F, T2>(self, f: F) -> Progress<P, T2, E> where
    F: FnOnce(T) -> T2, 
[src]

Maps the success value, if there is one.

If the current position is needed while mapping, see map_with_pos instead.

pub fn map_with_pos<F, T2>(self, f: F) -> Progress<P, T2, E> where
    F: FnOnce(T, P) -> T2,
    P: Clone
[src]

Maps the success value, if there is one.

pub fn and_then<T2, F>(self, restore_to: P, f: F) -> Progress<P, T2, E> where
    F: FnOnce(T) -> Result<T2, E>, 
[src]

Maps the success value, if there is one, potentially converting into a failure.

If the current position is needed while mapping, see and_then_with_pos instead.

pub fn and_then_with_pos<T2, F>(self, restore_to: P, f: F) -> Progress<P, T2, E> where
    F: FnOnce(T, P) -> Result<T2, E>,
    P: Clone
[src]

Maps the success value, if there is one, potentially converting into a failure.

pub fn map_err<E2, F>(self, f: F) -> Progress<P, T, E2> where
    F: FnOnce(E) -> E2, 
[src]

Maps the failure value, if there is one.

If the current position is needed while mapping, see map_err_with_pos instead.

pub fn map_err_with_pos<E2, F>(self, f: F) -> Progress<P, T, E2> where
    F: FnOnce(E, P) -> E2,
    P: Clone
[src]

Maps the failure value, if there is one.

pub fn into_optional(self, reset_to: P) -> (P, Option<T>)[src]

Returns the value and the current position on success, or resets the position and returns None on failure.

pub fn unwrap(self) -> (P, T)[src]

Unwraps itself into the position and the successfully parsed value.

Panics if the parse status is an Err.

pub fn unwrap_err(self) -> (P, E)[src]

Unwraps itself into the point and the error.

Panics if the parse status is not an Err.

pub fn finish(self) -> (P, Result<T, E>)[src]

Converts this progress into a position and a result.

Trait Implementations

impl<P: Clone, T: Clone, E: Clone> Clone for Progress<P, T, E>[src]

impl<P: Copy, T: Copy, E: Copy> Copy for Progress<P, T, E>[src]

impl<P: Debug, T: Debug, E: Debug> Debug for Progress<P, T, E>[src]

impl<P: PartialEq, T: PartialEq, E: PartialEq> PartialEq<Progress<P, T, E>> for Progress<P, T, E>[src]

impl<P, T, E> StructuralPartialEq for Progress<P, T, E>[src]

Auto Trait Implementations

impl<P, T, E> RefUnwindSafe for Progress<P, T, E> where
    E: RefUnwindSafe,
    P: RefUnwindSafe,
    T: RefUnwindSafe
[src]

impl<P, T, E> Send for Progress<P, T, E> where
    E: Send,
    P: Send,
    T: Send
[src]

impl<P, T, E> Sync for Progress<P, T, E> where
    E: Sync,
    P: Sync,
    T: Sync
[src]

impl<P, T, E> Unpin for Progress<P, T, E> where
    E: Unpin,
    P: Unpin,
    T: Unpin
[src]

impl<P, T, E> UnwindSafe for Progress<P, T, E> where
    E: UnwindSafe,
    P: UnwindSafe,
    T: UnwindSafe
[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.