nom
nom copied to clipboard
Make traits public
nom::traits
is private. In order to implement generic parsers, it would be helpful to have access to the type defs.
Or there is another way that I don't know?
Prerequisites
Here are a few things you should provide to help me understand the issue:
- Rust version :
rustc 1.67.0 (fc594f156 2023-01-24)
- nom version :
version = "7.1.3"
Test case
Example test case: Offset
and Slice
are part of nom's private traits module.
// I want to implement a similar parser to `recognize` that sends back the consumed input and the results
pub fn recognize_children<I: Clone + Offset + Slice<RangeTo<usize>>, O, E: ParseError<I>, F>(
mut parser: F,
) -> impl FnMut(I) -> IResult<I, (I, O), E>
where
F: Parser<I, O, E>,
{
move |input: I| {
let i = input.clone();
match parser.parse(i) {
Ok((i, o)) => {
let index = input.offset(&i);
Ok((i, (input.slice(..index), o)))
}
Err(e) => Err(e),
}
}
}
all the traits are exported at the root level: https://github.com/rust-bakery/nom/blob/main/src/lib.rs#L440