Use static strings for CustomError.
This resulted in a 20% speedup.
This commit is contained in:
parent
90433aa55f
commit
1b7326eafe
@ -4,10 +4,9 @@ use nom::IResult;
|
||||
|
||||
pub(crate) type Res<T, U> = IResult<T, U, CustomError<T>>;
|
||||
|
||||
// TODO: MyError probably shouldn't be based on the same type as the input type since it's used exclusively with static strings right now.
|
||||
#[derive(Debug)]
|
||||
pub enum CustomError<I> {
|
||||
MyError(MyError<I>),
|
||||
MyError(MyError<&'static str>),
|
||||
Nom(I, ErrorKind),
|
||||
IO(std::io::Error),
|
||||
}
|
||||
@ -31,3 +30,9 @@ impl<I> From<std::io::Error> for CustomError<I> {
|
||||
CustomError::IO(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<I> From<&'static str> for CustomError<I> {
|
||||
fn from(value: &'static str) -> Self {
|
||||
CustomError::MyError(MyError(value))
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user