From 6a4823461f491aef63451f097ddfe5602e0b2157 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 10 Jul 2021 20:01:18 +0200 Subject: Reference-count complex values Rename some nodes types --- src/syntax/span.rs | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/syntax/span.rs') 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 From for Span where T: Into + 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 Add for Pos -where - T: Into, -{ - type Output = Self; - - fn add(self, rhs: T) -> Self { - Pos(self.0 + rhs.into().0) - } -} - impl From for Pos { fn from(index: u32) -> Self { Self(index) @@ -207,6 +196,17 @@ impl Debug for Pos { } } +impl Add for Pos +where + T: Into, +{ + 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 { -- cgit v1.2.3