Skip to content

Commit

Permalink
Rename RuntimeTypeHashable -> RuntimeTypeMapKey
Browse files Browse the repository at this point in the history
Part of PR #700
  • Loading branch information
stepancheg committed Jun 25, 2024
1 parent ba59c43 commit 65f3f01
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions protobuf/src/reflect/acc/v2/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,7 +43,7 @@ impl<M, K, V> MapFieldAccessor for MapFieldAccessorImpl<M, K, V>
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> {
Expand Down Expand Up @@ -75,7 +75,7 @@ pub fn make_map_simpler_accessor<M, K, V>(
where
M: MessageFull + 'static,
K: ProtobufValue + Hash + Eq,
K::RuntimeType: RuntimeTypeHashable,
K::RuntimeType: RuntimeTypeMapKey,
V: ProtobufValue,
{
FieldAccessor::new(
Expand Down
6 changes: 3 additions & 3 deletions protobuf/src/reflect/map/generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,7 +16,7 @@ impl<K, V> ReflectMap for HashMap<K, V>
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() })
Expand All @@ -31,7 +31,7 @@ where
}

fn get<'a>(&'a self, key: ReflectValueRef) -> Option<ReflectValueRef<'a>> {
<K::RuntimeType as RuntimeTypeHashable>::hash_map_get(self, key).map(V::RuntimeType::as_ref)
<K::RuntimeType as RuntimeTypeMapKey>::hash_map_get(self, key).map(V::RuntimeType::as_ref)
}

fn insert(&mut self, key: ReflectValueBox, value: ReflectValueBox) {
Expand Down
18 changes: 9 additions & 9 deletions protobuf/src/reflect/runtime_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Value, V>, key: ReflectValueRef)
-> Option<&'a V>;
Expand Down Expand Up @@ -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<i32, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::I32(i) => map.get(&i),
Expand Down Expand Up @@ -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<i64, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::I64(i) => map.get(&i),
Expand Down Expand Up @@ -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<u32, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::U32(i) => map.get(&i),
Expand Down Expand Up @@ -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<u64, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::U64(i) => map.get(&i),
Expand Down Expand Up @@ -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<bool, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::Bool(i) => map.get(&i),
Expand Down Expand Up @@ -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<String, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::String(s) => map.get(*&s),
Expand Down Expand Up @@ -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<Chars, V>, key: ReflectValueRef) -> Option<&'a V> {
match key {
ReflectValueRef::String(s) => map.get(&*s),
Expand Down

0 comments on commit 65f3f01

Please sign in to comment.