implement deref &str on the tokens

This commit is contained in:
Irevoire
2021-11-09 11:34:10 +01:00
parent a211a9cdcd
commit 0ea0146e04
2 changed files with 17 additions and 8 deletions

View File

@ -40,6 +40,7 @@ mod error;
mod value;
use std::fmt::Debug;
use std::ops::Deref;
use std::str::FromStr;
pub use condition::{parse_condition, parse_to, Condition};
@ -63,6 +64,14 @@ type IResult<'a, Ret> = nom::IResult<Span<'a>, Ret, Error<'a>>;
#[derive(Debug, Clone, Eq)]
pub struct Token<'a>(Span<'a>);
impl<'a> Deref for Token<'a> {
type Target = &'a str;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'a> PartialEq for Token<'a> {
fn eq(&self, other: &Self) -> bool {
self.0.fragment() == other.0.fragment()