From 2e18783a2f6e29c225d177e8a0fb866a9c9d85df Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Tue, 19 Jul 2022 17:02:09 -0400 Subject: [Rust API] General type fixes and additions --- rust/src/string.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'rust/src/string.rs') 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(&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()) -- cgit v1.3.1