summaryrefslogtreecommitdiff
path: root/rust/src
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2021-02-10 22:02:50 +0000
committerKyleMiles <krm504@nyu.edu>2021-03-17 23:43:59 +0000
commit1515df8e71412787470b27d04ed9b2944fca0fdc (patch)
tree400fbc792da7de1cc62e0fae171aae2bdf346869 /rust/src
parent41e11f8387ebb3275da31994b85a7a8b6256eb99 (diff)
Misc typo changes, const changes, code cleanup, and example updates
Diffstat (limited to 'rust/src')
-rw-r--r--rust/src/binaryview.rs2
-rw-r--r--rust/src/symbol.rs20
2 files changed, 18 insertions, 4 deletions
diff --git a/rust/src/binaryview.rs b/rust/src/binaryview.rs
index a011b9e0..528e3374 100644
--- a/rust/src/binaryview.rs
+++ b/rust/src/binaryview.rs
@@ -620,7 +620,7 @@ pub struct BinaryView {
}
impl BinaryView {
- pub unsafe fn from_raw(handle: *mut BNBinaryView) -> Self {
+ pub(crate) unsafe fn from_raw(handle: *mut BNBinaryView) -> Self {
debug_assert!(!handle.is_null());
Self { handle }
diff --git a/rust/src/symbol.rs b/rust/src/symbol.rs
index 2b3aa463..c545d962 100644
--- a/rust/src/symbol.rs
+++ b/rust/src/symbol.rs
@@ -13,6 +13,7 @@
// limitations under the License.
use std::fmt;
+use std::hash::{Hash, Hasher};
use std::ptr;
use crate::rc::*;
@@ -165,9 +166,6 @@ pub struct Symbol {
pub(crate) handle: *mut BNSymbol,
}
-unsafe impl Send for Symbol {}
-unsafe impl Sync for Symbol {}
-
impl Symbol {
pub(crate) unsafe fn from_raw(raw: *mut BNSymbol) -> Self {
Self { handle: raw }
@@ -223,6 +221,9 @@ impl Symbol {
}
}
+unsafe impl Send for Symbol {}
+unsafe impl Sync for Symbol {}
+
impl fmt::Debug for Symbol {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
@@ -272,3 +273,16 @@ unsafe impl<'a> CoreOwnedArrayWrapper<'a> for Symbol {
Guard::new(Symbol::from_raw(*raw), context)
}
}
+
+impl PartialEq for Ref<Symbol> {
+ fn eq(&self, other: &Self) -> bool {
+ **self == **other
+ }
+}
+impl Eq for Ref<Symbol> {}
+
+impl Hash for Ref<Symbol> {
+ fn hash<H: Hasher>(&self, state: &mut H) {
+ (**self).hash(state);
+ }
+}