From 65f3f01220bd257231d1dc9500d0a2f8790164d7 Mon Sep 17 00:00:00 2001 From: Stepan Koltsov Date: Tue, 25 Jun 2024 23:37:49 +0100 Subject: [PATCH] Rename RuntimeTypeHashable -> RuntimeTypeMapKey Part of PR #700 --- protobuf/src/reflect/acc/v2/map.rs | 6 +++--- protobuf/src/reflect/map/generated.rs | 6 +++--- protobuf/src/reflect/runtime_types.rs | 18 +++++++++--------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/protobuf/src/reflect/acc/v2/map.rs b/protobuf/src/reflect/acc/v2/map.rs index 3d8df8b81..f9c342e55 100644 --- a/protobuf/src/reflect/acc/v2/map.rs +++ b/protobuf/src/reflect/acc/v2/map.rs @@ -8,7 +8,7 @@ use crate::reflect::acc::v2::AccessorV2; use crate::reflect::acc::FieldAccessor; use crate::reflect::map::ReflectMapMut; use crate::reflect::map::ReflectMapRef; -use crate::reflect::runtime_types::RuntimeTypeHashable; +use crate::reflect::runtime_types::RuntimeTypeMapKey; use crate::reflect::runtime_types::RuntimeTypeTrait; use crate::reflect::ProtobufValue; use crate::reflect::RuntimeType; @@ -43,7 +43,7 @@ impl MapFieldAccessor for MapFieldAccessorImpl where M: MessageFull, K: ProtobufValue + Eq + Hash, - K::RuntimeType: RuntimeTypeHashable, + K::RuntimeType: RuntimeTypeMapKey, V: ProtobufValue, { fn get_reflect<'a>(&self, m: &'a dyn MessageDyn) -> ReflectMapRef<'a> { @@ -75,7 +75,7 @@ pub fn make_map_simpler_accessor( where M: MessageFull + 'static, K: ProtobufValue + Hash + Eq, - K::RuntimeType: RuntimeTypeHashable, + K::RuntimeType: RuntimeTypeMapKey, V: ProtobufValue, { FieldAccessor::new( diff --git a/protobuf/src/reflect/map/generated.rs b/protobuf/src/reflect/map/generated.rs index ccece690f..0a5f200e9 100644 --- a/protobuf/src/reflect/map/generated.rs +++ b/protobuf/src/reflect/map/generated.rs @@ -5,7 +5,7 @@ use std::hash::Hash; use crate::reflect::map::ReflectMap; use crate::reflect::map::ReflectMapIter; use crate::reflect::map::ReflectMapIterTrait; -use crate::reflect::runtime_types::RuntimeTypeHashable; +use crate::reflect::runtime_types::RuntimeTypeMapKey; use crate::reflect::runtime_types::RuntimeTypeTrait; use crate::reflect::ProtobufValue; use crate::reflect::ReflectValueBox; @@ -16,7 +16,7 @@ impl ReflectMap for HashMap where K: ProtobufValue + Eq + Hash, V: ProtobufValue, - K::RuntimeType: RuntimeTypeHashable, + K::RuntimeType: RuntimeTypeMapKey, { fn reflect_iter<'a>(&'a self) -> ReflectMapIter<'a> { ReflectMapIter::new(GeneratedMapIterImpl::<'a, K, V> { iter: self.iter() }) @@ -31,7 +31,7 @@ where } fn get<'a>(&'a self, key: ReflectValueRef) -> Option> { - ::hash_map_get(self, key).map(V::RuntimeType::as_ref) + ::hash_map_get(self, key).map(V::RuntimeType::as_ref) } fn insert(&mut self, key: ReflectValueBox, value: ReflectValueBox) { diff --git a/protobuf/src/reflect/runtime_types.rs b/protobuf/src/reflect/runtime_types.rs index 26bfe9669..d10be194b 100644 --- a/protobuf/src/reflect/runtime_types.rs +++ b/protobuf/src/reflect/runtime_types.rs @@ -118,8 +118,8 @@ pub trait RuntimeTypeWithDeref: RuntimeTypeTrait { fn deref_as_ref(value: &Self::DerefTarget) -> ReflectValueRef; } -/// Types which can be hashmap keys. -pub trait RuntimeTypeHashable: RuntimeTypeTrait { +/// Types which can be map keys. +pub trait RuntimeTypeMapKey: RuntimeTypeTrait { /// Query hash map with a given key. fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V>; @@ -311,7 +311,7 @@ impl RuntimeTypeTrait for RuntimeTypeI32 { } } } -impl RuntimeTypeHashable for RuntimeTypeI32 { +impl RuntimeTypeMapKey for RuntimeTypeI32 { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::I32(i) => map.get(&i), @@ -370,7 +370,7 @@ impl RuntimeTypeTrait for RuntimeTypeI64 { } } } -impl RuntimeTypeHashable for RuntimeTypeI64 { +impl RuntimeTypeMapKey for RuntimeTypeI64 { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::I64(i) => map.get(&i), @@ -428,7 +428,7 @@ impl RuntimeTypeTrait for RuntimeTypeU32 { } } } -impl RuntimeTypeHashable for RuntimeTypeU32 { +impl RuntimeTypeMapKey for RuntimeTypeU32 { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::U32(i) => map.get(&i), @@ -486,7 +486,7 @@ impl RuntimeTypeTrait for RuntimeTypeU64 { } } } -impl RuntimeTypeHashable for RuntimeTypeU64 { +impl RuntimeTypeMapKey for RuntimeTypeU64 { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::U64(i) => map.get(&i), @@ -541,7 +541,7 @@ impl RuntimeTypeTrait for RuntimeTypeBool { ProtobufTypeBool::get_from_unknown(unknown) } } -impl RuntimeTypeHashable for RuntimeTypeBool { +impl RuntimeTypeMapKey for RuntimeTypeBool { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::Bool(i) => map.get(&i), @@ -599,7 +599,7 @@ impl RuntimeTypeWithDeref for RuntimeTypeString { ReflectValueRef::String(value) } } -impl RuntimeTypeHashable for RuntimeTypeString { +impl RuntimeTypeMapKey for RuntimeTypeString { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::String(s) => map.get(*&s), @@ -763,7 +763,7 @@ impl RuntimeTypeWithDeref for RuntimeTypeTokioChars { } } #[cfg(feature = "bytes")] -impl RuntimeTypeHashable for RuntimeTypeTokioChars { +impl RuntimeTypeMapKey for RuntimeTypeTokioChars { fn hash_map_get<'a, V>(map: &'a HashMap, key: ReflectValueRef) -> Option<&'a V> { match key { ReflectValueRef::String(s) => map.get(&*s),