Open Geal opened 3 years ago
Perhaps related too: https://github.com/rust-lang/rust/issues/30867
Also, even declared functions have this problem???? archive.ar.txt
To summarize from the two archives @cheako posted:
Making the error manually owned works as a workaround for now:
use nom_bufreader::bufreader::BufReader;
use nom_bufreader::Parse;
use nom::error::{ContextError, Error as NomError, ErrorKind, FromExternalError, ParseError};
#[derive(Debug, PartialEq)]
struct Error(NomError<Vec<u8>>);
impl ParseError<&'_ [u8]> for Error {
fn from_error_kind(input: &'_ [u8], kind: ErrorKind) -> Self {
Error(NomError::from_error_kind(input.to_owned(), kind))
}
fn append(_: &'_ [u8], _: ErrorKind, other: Self) -> Self {
other
}
}
impl ContextError<&'_ [u8]> for Error {}
impl<E> FromExternalError<&'_ [u8], E> for Error {
fn from_external_error(input: &'_ [u8], kind: ErrorKind, _e: E) -> Self {
Error(NomError::from_external_error(input.to_owned(), kind, _e))
}
}
fn list_ints(input: &[u8]) -> IResult<&[u8], Vec<u8>, Error> {
separated_list0(tag(","), u8)(input)
}
But to actually fix this usability problem for declared functions see #9
Disclaimer: quite new to Rust but loving the nom parser thus far
Apparently I cannot write this:
As it would result in this error: