Add some PartialEq impls for CxxString
diff --git a/src/cxx_string.rs b/src/cxx_string.rs
index 6b69435..d3d128c 100644
--- a/src/cxx_string.rs
+++ b/src/cxx_string.rs
@@ -89,3 +89,21 @@
Debug::fmt(self.to_string_lossy().as_ref(), f)
}
}
+
+impl PartialEq for CxxString {
+ fn eq(&self, other: &CxxString) -> bool {
+ self.as_bytes() == other.as_bytes()
+ }
+}
+
+impl PartialEq<CxxString> for str {
+ fn eq(&self, other: &CxxString) -> bool {
+ self.as_bytes() == other.as_bytes()
+ }
+}
+
+impl PartialEq<str> for CxxString {
+ fn eq(&self, other: &str) -> bool {
+ self.as_bytes() == other.as_bytes()
+ }
+}
diff --git a/tests/test.rs b/tests/test.rs
index 9f1ea24..87a18ad 100644
--- a/tests/test.rs
+++ b/tests/test.rs
@@ -45,14 +45,7 @@
"logic error",
ffi::c_fail_return_primitive().unwrap_err().what(),
);
- assert_eq!(
- "ok",
- ffi::c_try_return_string()
- .unwrap()
- .as_ref()
- .unwrap()
- .to_string()
- );
+ assert_eq!("ok", ffi::c_try_return_string().unwrap().as_ref().unwrap());
assert_eq!(
"logic error getting string",
ffi::c_fail_return_string().unwrap_err().what(),