pub struct FnParser<F> { /* private fields */ }Expand description
関数ポインタを Parser としてラップする。
recursive() の Box<dyn Parser> + vtable を回避し、
通常の関数呼び出しで再帰パーサーを構築できる。
ⓘ
fn my_value<'a>(input: &mut StrInput<'a>) -> PResult<Json, ParseError> {
// 先頭バイトで分岐 → 各コンビネータを呼ぶ
// 再帰は fn_parser(my_value) で自分自身を参照
}
let parser = fn_parser(my_value);Trait Implementations§
Auto Trait Implementations§
impl<F> Freeze for FnParser<F>where
F: Freeze,
impl<F> RefUnwindSafe for FnParser<F>where
F: RefUnwindSafe,
impl<F> Send for FnParser<F>where
F: Send,
impl<F> Sync for FnParser<F>where
F: Sync,
impl<F> Unpin for FnParser<F>where
F: Unpin,
impl<F> UnsafeUnpin for FnParser<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for FnParser<F>where
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<I, P> ParserExt<I> for P
impl<I, P> ParserExt<I> for P
fn map<F, O2>(self, f: F) -> Map<Self, F>
fn zip<P2>(self, rhs: P2) -> Zip<Self, P2>
fn or<P2>(self, rhs: P2) -> Or<Self, P2>
fn attempt(self) -> Attempt<Self>
fn cut(self) -> Cut<Self>
fn optional(self) -> Optional<Self>
fn many0(self) -> Many<Self>
fn many1(self) -> Many1<Self>
Source§fn context(self, label: &'static str) -> Context<Self>where
Self::Error: ContextError,
fn context(self, label: &'static str) -> Context<Self>where
Self::Error: ContextError,
エラーにコンテキストラベルを付与する。
Source§fn chainl1<Op, F>(self, op: Op) -> ChainL1<Self, Op>
fn chainl1<Op, F>(self, op: Op) -> ChainL1<Self, Op>
左結合の二項演算子チェーン。operand (op operand)* を左から畳む。
Source§fn chainr1<Op, F>(self, op: Op) -> ChainR1<Self, Op>
fn chainr1<Op, F>(self, op: Op) -> ChainR1<Self, Op>
右結合の二項演算子チェーン。operand (op operand)* を右から畳む。