Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/intern/src/symbol.rs')
-rw-r--r--crates/intern/src/symbol.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/crates/intern/src/symbol.rs b/crates/intern/src/symbol.rs
index 0fa6701ca3..f6a74d9741 100644
--- a/crates/intern/src/symbol.rs
+++ b/crates/intern/src/symbol.rs
@@ -42,6 +42,18 @@ struct TaggedArcPtr {
unsafe impl Send for TaggedArcPtr {}
unsafe impl Sync for TaggedArcPtr {}
+impl Ord for TaggedArcPtr {
+ fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+ self.as_str().cmp(other.as_str())
+ }
+}
+
+impl PartialOrd for TaggedArcPtr {
+ fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+ Some(self.cmp(other))
+ }
+}
+
impl TaggedArcPtr {
const BOOL_BITS: usize = true as usize;
@@ -113,7 +125,7 @@ impl TaggedArcPtr {
}
}
-#[derive(PartialEq, Eq, Hash)]
+#[derive(PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct Symbol {
repr: TaggedArcPtr,
}