diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-07-19 17:02:09 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-09-29 21:02:21 -0400 |
| commit | 2e18783a2f6e29c225d177e8a0fb866a9c9d85df (patch) | |
| tree | 4921f16f509eaad788fafbda6ead42d79b05b82f /rust/src/string.rs | |
| parent | 83eddd3eddc54b6362b5db37da0d1a28a115e7db (diff) | |
[Rust API] General type fixes and additions
Diffstat (limited to 'rust/src/string.rs')
| -rw-r--r-- | rust/src/string.rs | 15 |
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()) |
