implment `Ord`, `PartialOrd` and `Hash` for CxxString.
diff --git a/src/cxx_string.rs b/src/cxx_string.rs
index 8834b49..c132189 100644
--- a/src/cxx_string.rs
+++ b/src/cxx_string.rs
@@ -183,6 +183,38 @@
}
}
+impl Eq for CxxString {}
+
+impl PartialOrd for CxxString {
+ fn partial_cmp(&self, other: &Self) -> Option<core::cmp::Ordering> {
+ self.as_bytes().partial_cmp(other.as_bytes())
+ }
+}
+
+impl PartialOrd<str> for CxxString {
+ fn partial_cmp(&self, other: &str) -> Option<core::cmp::Ordering> {
+ self.as_bytes().partial_cmp(other.as_bytes())
+ }
+}
+
+impl PartialOrd<CxxString> for str {
+ fn partial_cmp(&self, other: &CxxString) -> Option<core::cmp::Ordering> {
+ self.as_bytes().partial_cmp(other.as_bytes())
+ }
+}
+
+impl Ord for CxxString {
+ fn cmp(&self, other: &Self) -> core::cmp::Ordering {
+ self.as_bytes().cmp(other.as_bytes())
+ }
+}
+
+impl core::hash::Hash for CxxString {
+ fn hash<H: core::hash::Hasher>(&self, state: &mut H) {
+ self.as_bytes().hash(state)
+ }
+}
+
#[doc(hidden)]
#[repr(C)]
pub struct StackString {