nom

Trait Mode

Source
pub trait Mode {
    type Output<T>;

    // Required methods
    fn bind<T, F: FnOnce() -> T>(f: F) -> Self::Output<T>;
    fn map<T, U, F: FnOnce(T) -> U>(x: Self::Output<T>, f: F) -> Self::Output<U>;
    fn combine<T, U, V, F: FnOnce(T, U) -> V>(
        x: Self::Output<T>,
        y: Self::Output<U>,
        f: F,
    ) -> Self::Output<V>;
}
Expand description

Parser mode: influences how combinators build values

the Parser trait is generic over types implementing Mode. Its method are called to produce and manipulate output values or errors.

The main implementations of this trait are:

  • Emit: produce a value
  • Check: apply the parser but do not generate a value

Required Associated Types§

Source

type Output<T>

The output type that may be generated

Required Methods§

Source

fn bind<T, F: FnOnce() -> T>(f: F) -> Self::Output<T>

Produces a value

Source

fn map<T, U, F: FnOnce(T) -> U>(x: Self::Output<T>, f: F) -> Self::Output<U>

Applies a function over the produced value

Source

fn combine<T, U, V, F: FnOnce(T, U) -> V>( x: Self::Output<T>, y: Self::Output<U>, f: F, ) -> Self::Output<V>

Combines two values generated by previous parsers

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Mode for Check

Source§

type Output<T> = ()

Source§

impl Mode for Emit

Source§

type Output<T> = T