From 5ebe1ddc57a96aaf3d9380da54943145d911895b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 21 May 2020 18:14:51 -0700 Subject: [PATCH] Impl Ord for LineColumn --- src/lib.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 4b65794d..f5c787fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -317,6 +317,20 @@ pub struct LineColumn { pub column: usize, } +#[cfg(span_locations)] +impl Ord for LineColumn { + fn cmp(&self, other: &Self) -> Ordering { + self.line.cmp(&other.line).then(self.column.cmp(&other.column)) + } +} + +#[cfg(span_locations)] +impl PartialOrd for LineColumn { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + /// A region of source code, along with macro expansion information. #[derive(Copy, Clone)] pub struct Span {