&[& [u8]]
, how could I make it working with nom?
take_until
45 | pub fn alt<I: Clone, O, E: ParseError<I>, List: Alt<I, O, E>>(l: List) -> impl Fn(I) -> IResult<I, O, E> {
| ------------ required by this bound in `nom::branch::alt`
|
= note: expected enum `std::result::Result<(&str, &str), nom::internal::Err<(&str, nom::error::ErrorKind)>>`
found enum `std::result::Result<(&str, screen::settings::administration::parse_search::Criteria<'_>), nom::internal::Err<(&str, nom::error::ErrorKind)>>`
tuple
that returns a single slice
recognize
looks like it'll help
fn ident(s: &[u8]) -> IResult<&[u8], &[u8]> {
recognize(preceded(
|i| if let Some(&l) = s.get(0) {
if letter(l) {
Ok((&s[1..], ()))
} else {
Err(Err::Error(ParseError::from_error_kind(s, ErrorKind::OneOf)))
}
} else {
Err(Err::Incomplete(Needed::Size(1)))
},
take_while(|b| matches!(b, b'A'..=b'Z' | b'a'..=b'z' | b'_' | b'0'..=b'9'))
))(s)
}
alt
it says "with a custom error type, it is possible to have alt return the error of the parser that went the farthest in the input data" but there seems to not be any documentation on how to do this
Incomplete
, not an error
. How would I get my desired behaivior?
let (input, defs) = complete(many1(annotated_terminal(alt((
p_fn_named,
p_prim,
p_struct,
p_enum,
)))))(input)?;