oni_comb_parser_rs::prelude

Enum ParseResult

Source
pub enum ParseResult<'a, I, A> {
    Success {
        value: A,
        length: usize,
    },
    Failure {
        error: ParseError<'a, I>,
        committed_status: CommittedStatus,
    },
}
Expand description

The enum type representing the parse result.
解析結果を示す列挙型。

Variants§

§

Success

Success.
成功

Fields

§value: A

The value when success.
成功の値

§length: usize

The size of the value. valueのサイズ

§

Failure

Failure.
失敗

Fields

§error: ParseError<'a, I>

The cause when failure.
失敗の原因

§committed_status: CommittedStatus

The commit status.
コミット状態

Implementations§

Source§

impl<'a, I, A> ParseResult<'a, I, A>

Source

pub fn successful(value: A, length: usize) -> Self

Returns the parse result of success.
成功の解析結果を返します。

  • value: a value

  • length: a size of the value

  • value: 値

  • length: 値のサイズ

Source

pub fn failed( error: ParseError<'a, I>, committed_status: CommittedStatus, ) -> Self

Returns the parse result of failure.
失敗の解析結果を返します。

Source

pub fn failed_with_uncommitted(error: ParseError<'a, I>) -> Self

Returns the parse result of failure.
失敗の解析結果を返します。

  • error: a [ParsedError]
Source

pub fn failed_with_commit(error: ParseError<'a, I>) -> Self

Source

pub fn to_result(self) -> Result<A, ParseError<'a, I>>

Convert [ParsedResult] to Result.
[ParsedResult]をResultに変換する。

Source

pub fn is_success(&self) -> bool

Returns whether the parsing was successful or not.
解析が成功したかどうかを返す。

Source

pub fn success(self) -> Option<A>

Return the results of a successful parsing.
成功した解析結果を返す。

Source

pub fn is_failure(&self) -> bool

Returns whether the parsing has failed or not.
解析が失敗したかどうかを返す。

Source

pub fn failure(self) -> Option<ParseError<'a, I>>

Return the result of the failed parsing.
失敗した解析結果を返す。

Source

pub fn committed_status(&self) -> Option<CommittedStatus>

Return the committed status.
コミット状態を返す。

Source

pub fn with_uncommitted(self) -> Self

失敗時のコミットを解除する

Source

pub fn with_committed_fallback(self, is_committed: bool) -> Self

Source

pub fn flat_map<B, F>(self, f: F) -> ParseResult<'a, I, B>
where F: Fn(A, usize) -> ParseResult<'a, I, B>,

Source

pub fn map<B, F>(self, f: F) -> ParseResult<'a, I, B>
where F: Fn(A, usize) -> (B, usize),

Source

pub fn map_err<F>(self, f: F) -> Self
where F: Fn(ParseError<'a, I>) -> ParseError<'a, I>,

Source

pub fn with_add_length(self, n: usize) -> Self

Trait Implementations§

Source§

impl<'a, I: Clone, A: Clone> Clone for ParseResult<'a, I, A>

Source§

fn clone(&self) -> ParseResult<'a, I, A>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a, I: Debug, A: Debug> Debug for ParseResult<'a, I, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, I, A> Freeze for ParseResult<'a, I, A>
where A: Freeze,

§

impl<'a, I, A> RefUnwindSafe for ParseResult<'a, I, A>

§

impl<'a, I, A> Send for ParseResult<'a, I, A>
where A: Send, I: Sync,

§

impl<'a, I, A> Sync for ParseResult<'a, I, A>
where A: Sync, I: Sync,

§

impl<'a, I, A> Unpin for ParseResult<'a, I, A>
where A: Unpin,

§

impl<'a, I, A> UnwindSafe for ParseResult<'a, I, A>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.