summaryrefslogtreecommitdiff
path: root/rust/src/string.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rust/src/string.rs')
-rw-r--r--rust/src/string.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/rust/src/string.rs b/rust/src/string.rs
index e6de576b..42ff4fdc 100644
--- a/rust/src/string.rs
+++ b/rust/src/string.rs
@@ -17,6 +17,7 @@
use std::borrow::{Borrow, Cow};
use std::ffi::{CStr, CString};
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::mem;
use std::ops::Deref;
use std::os::raw;
@@ -163,6 +164,20 @@ impl AsRef<[u8]> for BnString {
}
}
+impl Hash for BnString {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ self.raw.hash(state)
+ }
+}
+
+impl PartialEq for BnString {
+ fn eq(&self, other: &Self) -> bool {
+ self.deref() == other.deref()
+ }
+}
+
+impl Eq for BnString {}
+
impl fmt::Display for BnString {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.as_cstr().to_string_lossy())