-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
only declared function parsers can be used #3
Comments
Perhaps related too: rust-lang/rust#30867 |
Also, even declared functions have this problem???? |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Apparently I cannot write this:
As it would result in this error:
The text was updated successfully, but these errors were encountered: