Implement Hash for RegistryKey. Closes #57

This commit is contained in:
Alex Orlenko
2021-06-16 12:12:42 +01:00
parent 9f0378b77e
commit 3b94b4e86f
2 changed files with 33 additions and 0 deletions
+15
View File
@@ -1,4 +1,5 @@
use std::cell::RefCell;
use std::hash::{Hash, Hasher};
use std::os::raw::{c_int, c_void};
use std::sync::{Arc, Mutex};
use std::{fmt, mem, ptr};
@@ -67,6 +68,20 @@ impl fmt::Debug for RegistryKey {
}
}
impl Hash for RegistryKey {
fn hash<H: Hasher>(&self, state: &mut H) {
self.registry_id.hash(state)
}
}
impl PartialEq for RegistryKey {
fn eq(&self, other: &RegistryKey) -> bool {
self.registry_id == other.registry_id && Arc::ptr_eq(&self.unref_list, &other.unref_list)
}
}
impl Eq for RegistryKey {}
impl Drop for RegistryKey {
fn drop(&mut self) {
let mut unref_list = mlua_expect!(self.unref_list.lock(), "unref list poisoned");