Skip to content

Commit

Permalink
Merge pull request #230 from dtolnay/ord
Browse files Browse the repository at this point in the history
Impl Ord for LineColumn
  • Loading branch information
dtolnay authored May 23, 2020
2 parents 0f91e81 + 5ebe1dd commit 1ea7745
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Ordering> {
Some(self.cmp(other))
}
}

/// A region of source code, along with macro expansion information.
#[derive(Copy, Clone)]
pub struct Span {
Expand Down

0 comments on commit 1ea7745

Please sign in to comment.