refactor: do not enforce the internal key of RcMap to be Clone

This commit is contained in:
JasterV 2025-12-01 12:15:41 +01:00
parent fd0d761e17
commit db6424b8ad

View file

@ -17,7 +17,7 @@ use std::{
#[derive(Debug)] #[derive(Debug)]
pub struct ObjectRef<K, V> pub struct ObjectRef<K, V>
where where
K: Hash + Eq + Clone, K: Hash + Eq,
{ {
parent_ref: Weak<DashMap<K, (AtomicIsize, V)>>, parent_ref: Weak<DashMap<K, (AtomicIsize, V)>>,
key: K, key: K,
@ -35,7 +35,7 @@ where
impl<K, V> Drop for ObjectRef<K, V> impl<K, V> Drop for ObjectRef<K, V>
where where
K: Hash + Eq + Clone, K: Hash + Eq,
{ {
fn drop(&mut self) { fn drop(&mut self) {
let Some(map) = self.parent_ref.upgrade() else { let Some(map) = self.parent_ref.upgrade() else {
@ -56,7 +56,7 @@ where
#[derive(thiserror::Error, Debug)] #[derive(thiserror::Error, Debug)]
pub enum InsertError<K, V> pub enum InsertError<K, V>
where where
K: Hash + Eq + Clone + Debug, K: Hash + Eq + Debug,
{ {
#[error( #[error(
"An entry already exists with the given key: '{0:?}'. You must wait until all existing object references are dropped for the pair to be removed." "An entry already exists with the given key: '{0:?}'. You must wait until all existing object references are dropped for the pair to be removed."