Function chomp::combinators::look_ahead [] [src]

pub fn look_ahead<'a, I, T, E, F>(i: Input<'a, I>, f: F) -> ParseResult<'a, I, T, E> where F: FnOnce(Input<'a, I>) -> ParseResult<'a, I, T, E>

Applies the parser F without consuming any input.

use chomp::{parse_only, take};
use chomp::combinators::look_ahead;

let p = |i| look_ahead(i, |i| take(i, 4)).bind(|i, t| take(i, 7).map(|u| (t, u)));

assert_eq!(parse_only(p, b"testing"), Ok((&b"test"[..], &b"testing"[..])));