use nom::{bytes::complete::tag, error::VerboseError, IResult};
pub type ParserOutput<'a, T> = IResult<&'a str, T, VerboseError<&'a str>>;
pub(crate) trait Parsable<'a> {
type Output;
fn parse(input: &'a str) -> ParserOutput<'a, Self::Output>;
}
pub(crate) fn hash(input: &str) -> IResult<&str, &str, VerboseError<&str>> {
tag("#")(input)
}
pub(crate) fn newline(input: &str) -> IResult<&str, &str, VerboseError<&str>> {
tag("\n")(input)
}
pub(crate) fn equal(input: &str) -> IResult<&str, &str, VerboseError<&str>> {
tag("=")(input)
}
pub(crate) fn to_owned_input(
error: nom::Err<VerboseError<&str>>,
) -> nom::Err<VerboseError<String>> {
error.map(|error| VerboseError {
errors: error
.errors
.into_iter()
.map(|(a, b)| (a.to_string(), b))
.collect::<Vec<_>>(),
})
}