use nom::bytes::complete::tag; use nom::error::ErrorKind; use nom::error::ParseError; use nom::error::VerboseError; use nom::IResult; #[derive(Debug, PartialEq)] pub enum CustomError { MyError(MyError), Nom(I, ErrorKind), } #[derive(Debug, PartialEq)] pub struct MyError(I); impl ParseError for CustomError { fn from_error_kind(input: I, kind: ErrorKind) -> Self { CustomError::Nom(input, kind) } fn append(input: I, kind: ErrorKind, mut other: Self) -> Self { // Doesn't do append like VerboseError other } } // Err(nom::Err::Error(nom::error::Error::from_error_kind(input, nom::error::ErrorKind::Char))) fn test_parser<'a>(i: &'a str) -> IResult<&'a str, &'a str, CustomError<&'a str>> { Err(nom::Err::Error(CustomError::MyError(MyError(i))))?; tag("sdjfisdfjisudfjuwiefweufefefjwef")(i) }