[−][src]Struct pahs::Progress
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]
F: FnOnce(T) -> T2,
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]
F: FnOnce(T, P) -> T2,
P: Clone,
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]
F: FnOnce(T) -> Result<T2, E>,
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]
F: FnOnce(T, P) -> Result<T2, E>,
P: Clone,
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]
F: FnOnce(E) -> E2,
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]
F: FnOnce(E, P) -> E2,
P: Clone,
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]
pub fn eq(&self, other: &Progress<P, T, E>) -> bool
[src]
pub fn ne(&self, other: &Progress<P, T, E>) -> bool
[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]
E: RefUnwindSafe,
P: RefUnwindSafe,
T: RefUnwindSafe,
impl<P, T, E> Send for Progress<P, T, E> where
E: Send,
P: Send,
T: Send,
[src]
E: Send,
P: Send,
T: Send,
impl<P, T, E> Sync for Progress<P, T, E> where
E: Sync,
P: Sync,
T: Sync,
[src]
E: Sync,
P: Sync,
T: Sync,
impl<P, T, E> Unpin for Progress<P, T, E> where
E: Unpin,
P: Unpin,
T: Unpin,
[src]
E: Unpin,
P: Unpin,
T: Unpin,
impl<P, T, E> UnwindSafe for Progress<P, T, E> where
E: UnwindSafe,
P: UnwindSafe,
T: UnwindSafe,
[src]
E: UnwindSafe,
P: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,