Function chumsky::primitive::todo

source ·
pub fn todo<I, O, E>() -> Todo<I, O, E>
Expand description

A parser that can be used wherever you need to implement a parser later.

This parser is analogous to the todo! and unimplemented! macros, but will produce a panic when used to parse input, not immediately when invoked.

This function is useful when developing your parser, allowing you to prototype and run parts of your parser without committing to implementing the entire thing immediately.

The output type of this parser is whatever you want it to be: it’ll never produce output!

Examples

let int = just::<_, _, Simple<char>>("0x").ignore_then(todo())
    .or(just("0b").ignore_then(text::digits(2)))
    .or(text::int(10));

// Decimal numbers are parsed
assert_eq!(int.parse("12"), Ok("12".to_string()));
// Binary numbers are parsed
assert_eq!(int.parse("0b00101"), Ok("00101".to_string()));
// Parsing hexadecimal numbers results in a panic because the parser is unimplemented
int.parse("0xd4");