From e2fe23b0dd69e1e6ac05c99ecac2f1eb6b8a6c90 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 3 May 2022 23:50:43 -0400 Subject: [PATCH] Add Ord and PartialOrd to RocStr --- roc_std/src/roc_str.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roc_std/src/roc_str.rs b/roc_std/src/roc_str.rs index b4c3f143fa..e62965f5bb 100644 --- a/roc_std/src/roc_str.rs +++ b/roc_std/src/roc_str.rs @@ -97,6 +97,18 @@ impl PartialEq for RocStr { impl Eq for RocStr {} +impl PartialOrd for RocStr { + fn partial_cmp(&self, other: &Self) -> Option { + self.as_str().partial_cmp(other.as_str()) + } +} + +impl Ord for RocStr { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + self.as_str().cmp(other.as_str()) + } +} + impl Debug for RocStr { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { self.deref().fmt(f)