re-implement the equality between tokens to only compare the inner value

This commit is contained in:
Tamo 2021-11-06 16:02:27 +01:00
parent b249989bef
commit 075d9c97c0
No known key found for this signature in database
GPG Key ID: 20CD8020AFA88D69

View File

@ -60,12 +60,18 @@ pub type Span<'a> = LocatedSpan<&'a str, &'a str>;
type IResult<'a, Ret> = nom::IResult<Span<'a>, Ret, Error<'a>>; type IResult<'a, Ret> = nom::IResult<Span<'a>, Ret, Error<'a>>;
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, Eq)]
pub struct Token<'a> { pub struct Token<'a> {
pub position: Span<'a>, pub position: Span<'a>,
pub inner: &'a str, pub inner: &'a str,
} }
impl<'a> PartialEq for Token<'a> {
fn eq(&self, other: &Self) -> bool {
self.inner == other.inner
}
}
impl<'a> Token<'a> { impl<'a> Token<'a> {
pub fn new(position: Span<'a>) -> Self { pub fn new(position: Span<'a>) -> Self {
Self { position, inner: &position } Self { position, inner: &position }