diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-10 20:01:18 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-10 23:10:17 +0200 |
| commit | 6a4823461f491aef63451f097ddfe5602e0b2157 (patch) | |
| tree | ad11b0ad169d030942d950573c729d50f7b3291b /src/syntax/span.rs | |
| parent | 36b3067c19c8743032a44f888ee48702b88d135b (diff) | |
Reference-count complex values
Rename some nodes types
Diffstat (limited to 'src/syntax/span.rs')
| -rw-r--r-- | src/syntax/span.rs | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/syntax/span.rs b/src/syntax/span.rs index f9b1d312..8a630faa 100644 --- a/src/syntax/span.rs +++ b/src/syntax/span.rs @@ -120,20 +120,6 @@ impl Span { } } -impl Eq for Span {} - -impl PartialEq for Span { - fn eq(&self, other: &Self) -> bool { - !Self::cmp() || (self.start == other.start && self.end == other.end) - } -} - -impl Default for Span { - fn default() -> Self { - Span::ZERO - } -} - impl<T> From<T> for Span where T: Into<Pos> + Copy, @@ -152,12 +138,26 @@ where } } +impl Default for Span { + fn default() -> Self { + Span::ZERO + } +} + impl Debug for Span { fn fmt(&self, f: &mut Formatter) -> fmt::Result { write!(f, "<{:?}-{:?}>", self.start, self.end) } } +impl Eq for Span {} + +impl PartialEq for Span { + fn eq(&self, other: &Self) -> bool { + !Self::cmp() || (self.start == other.start && self.end == other.end) + } +} + /// A byte position in source code. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)] pub struct Pos(pub u32); @@ -172,17 +172,6 @@ impl Pos { } } -impl<T> Add<T> for Pos -where - T: Into<Pos>, -{ - type Output = Self; - - fn add(self, rhs: T) -> Self { - Pos(self.0 + rhs.into().0) - } -} - impl From<u32> for Pos { fn from(index: u32) -> Self { Self(index) @@ -207,6 +196,17 @@ impl Debug for Pos { } } +impl<T> Add<T> for Pos +where + T: Into<Pos>, +{ + type Output = Self; + + fn add(self, rhs: T) -> Self { + Pos(self.0 + rhs.into().0) + } +} + /// A one-indexed line-column position in source code. #[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Serialize, Deserialize)] pub struct Location { |
