Skip to content

Commit 6f09250

Browse files
authoredFeb 8, 2024··
feat(source): derive common traits for NamedSource, SourceSpan, and SourceOffset (#340)
1 parent c2f06f6 commit 6f09250

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
 

‎src/named_source.rs

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{MietteError, MietteSpanContents, SourceCode, SpanContents};
33
/// Utility struct for when you have a regular [`SourceCode`] type that doesn't
44
/// implement `name`. For example [`String`]. Or if you want to override the
55
/// `name` returned by the `SourceCode`.
6+
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
67
pub struct NamedSource<S: SourceCode + 'static> {
78
source: S,
89
name: String,

‎src/protocol.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ impl<'a> SpanContents<'a> for MietteSpanContents<'a> {
550550
}
551551

552552
/// Span within a [`SourceCode`]
553-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
553+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
554554
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
555555
pub struct SourceSpan {
556556
/// The start of the span.
@@ -652,7 +652,7 @@ pub type ByteOffset = usize;
652652
/**
653653
Newtype that represents the [`ByteOffset`] from the beginning of a [`SourceCode`]
654654
*/
655-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash)]
655+
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
656656
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
657657
pub struct SourceOffset(ByteOffset);
658658

0 commit comments

Comments
 (0)
Please sign in to comment.