makes the parse function part of the filter_parser

This commit is contained in:
Tamo
2021-11-05 10:46:54 +01:00
parent 76d961cc77
commit 27a6a26b4b
2 changed files with 16 additions and 22 deletions

View File

@ -40,6 +40,7 @@ mod error;
mod value;
use std::fmt::Debug;
use std::str::FromStr;
pub use condition::{parse_condition, parse_to, Condition};
use error::{cut_with_err, ExtendNomError};
@ -73,6 +74,14 @@ impl<'a> Token<'a> {
pub fn as_external_error(&self, error: impl std::error::Error) -> Error<'a> {
Error::new_from_external(self.position, error)
}
pub fn parse<T>(&self) -> Result<T, Error>
where
T: FromStr,
T::Err: std::error::Error,
{
self.inner.parse().map_err(|e| self.as_external_error(e))
}
}
impl<'a> From<Span<'a>> for Token<'a> {