#refactor Simplify maps through the new ProxiedInMapValue<K> trait

This change is a pure refactoring and simplification of the code. We replace all MapsWith<TYPE>KeyOps traits through a single generic ProxiedInMapValue<K> trait. Through connecting the runtime maps implementation with Proxied the code gets a lot simpler e.g. we can use View<T> instead of hardcoding the concrete type behind it.

I also expect this change to be beneficial for the gencode. In a subsequent CL we'll implement message values for maps. After this change we'll only have to implement a single trait, while before we had to implement num(key types) many traits.

PiperOrigin-RevId: 596562909
pull/15333/head
Jakob Buchgraber 1 year ago committed by Copybara-Service
parent 1a21cb57b7
commit 991a2f4d54
  1. 115
      rust/cpp.rs
  2. 212
      rust/map.rs
  3. 4
      rust/test/shared/accessors_map_test.rs
  4. 111
      rust/upb.rs

@ -341,67 +341,49 @@ impl<'msg, K: ?Sized, V: ?Sized> Clone for MapInner<'msg, K, V> {
}
}
macro_rules! generate_map_with_key_ops_traits {
($($t:ty, $sized_t:ty;)*) => {
paste! {
$(
pub trait [< MapWith $t:camel KeyOps >] : Proxied {
fn new_map() -> RawMap;
fn clear(m: RawMap);
fn size(m: RawMap) -> usize;
fn insert(m: RawMap, key: $sized_t, value: View<'_, Self>) -> bool;
fn get<'msg>(m: RawMap, key: $sized_t) -> Option<View<'msg, Self>>;
fn remove(m: RawMap, key: $sized_t) -> bool;
}
pub trait ProxiedInMapValue<K>: Proxied
where
K: Proxied + ?Sized,
{
fn new_map() -> RawMap;
fn clear(m: RawMap);
fn size(m: RawMap) -> usize;
fn insert(m: RawMap, key: View<'_, K>, value: View<'_, Self>) -> bool;
fn get<'msg>(m: RawMap, key: View<'_, K>) -> Option<View<'msg, Self>>;
fn remove(m: RawMap, key: View<'_, K>) -> bool;
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + ?Sized> Default for MapInner<'msg, $t, V> {
fn default() -> Self {
MapInner {
raw: V::new_map(),
_phantom_key: PhantomData,
_phantom_value: PhantomData
}
}
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> Default for MapInner<'msg, K, V> {
fn default() -> Self {
MapInner { raw: V::new_map(), _phantom_key: PhantomData, _phantom_value: PhantomData }
}
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + ?Sized> MapInner<'msg, $t, V> {
pub fn size(&self) -> usize {
V::size(self.raw)
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> MapInner<'msg, K, V> {
pub fn size(&self) -> usize {
V::size(self.raw)
}
pub fn clear(&mut self) {
V::clear(self.raw)
}
pub fn clear(&mut self) {
V::clear(self.raw)
}
pub fn get<'a>(&self, key: $sized_t) -> Option<View<'a, V>> {
V::get(self.raw, key)
}
pub fn get<'a>(&self, key: View<'_, K>) -> Option<View<'a, V>> {
V::get(self.raw, key)
}
pub fn remove(&mut self, key: $sized_t) -> bool {
V::remove(self.raw, key)
}
pub fn remove(&mut self, key: View<'_, K>) -> bool {
V::remove(self.raw, key)
}
pub fn insert(&mut self, key: $sized_t, value: View<'_, V>) -> bool {
V::insert(self.raw, key, value);
true
}
}
)*
}
pub fn insert(&mut self, key: View<'_, K>, value: View<'_, V>) -> bool {
V::insert(self.raw, key, value);
true
}
}
generate_map_with_key_ops_traits!(
i32, i32;
u32, u32;
i64, i64;
u64, u64;
bool, bool;
ProtoStr, &ProtoStr;
);
macro_rules! impl_scalar_map_with_key_op_for_scalar_values {
($key_t:ty, $sized_key_t:ty, $ffi_key_t:ty, $to_ffi_key:expr, $trait:ident for $($t:ty, $ffi_t:ty, $to_ffi_value:expr, $from_ffi_value:expr, $zero_val:literal;)*) => {
macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types {
($key_t:ty, $ffi_key_t:ty, $to_ffi_key:expr, for $($t:ty, $ffi_t:ty, $to_ffi_value:expr, $from_ffi_value:expr, $zero_val:literal;)*) => {
paste! { $(
extern "C" {
fn [< __pb_rust_Map_ $key_t _ $t _new >]() -> RawMap;
@ -411,7 +393,8 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values {
fn [< __pb_rust_Map_ $key_t _ $t _get >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool;
fn [< __pb_rust_Map_ $key_t _ $t _remove >](m: RawMap, key: $ffi_key_t, value: *mut $ffi_t) -> bool;
}
impl $trait for $t {
impl ProxiedInMapValue<$key_t> for $t {
fn new_map() -> RawMap {
unsafe { [< __pb_rust_Map_ $key_t _ $t _new >]() }
}
@ -424,14 +407,14 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values {
unsafe { [< __pb_rust_Map_ $key_t _ $t _size >](m) }
}
fn insert(m: RawMap, key: $sized_key_t, value: View<'_, Self>) -> bool {
fn insert(m: RawMap, key: View<'_, $key_t>, value: View<'_, Self>) -> bool {
let ffi_key = $to_ffi_key(key);
let ffi_value = $to_ffi_value(value);
unsafe { [< __pb_rust_Map_ $key_t _ $t _insert >](m, ffi_key, ffi_value) }
true
}
fn get<'msg>(m: RawMap, key: $sized_key_t) -> Option<View<'msg, Self>> {
fn get<'msg>(m: RawMap, key: View<'_, $key_t>) -> Option<View<'msg, Self>> {
let ffi_key = $to_ffi_key(key);
let mut ffi_value = $to_ffi_value($zero_val);
let found = unsafe { [< __pb_rust_Map_ $key_t _ $t _get >](m, ffi_key, &mut ffi_value) };
@ -441,7 +424,7 @@ macro_rules! impl_scalar_map_with_key_op_for_scalar_values {
Some($from_ffi_value(ffi_value))
}
fn remove(m: RawMap, key: $sized_key_t) -> bool {
fn remove(m: RawMap, key: View<'_, $key_t>) -> bool {
let ffi_key = $to_ffi_key(key);
let mut ffi_value = $to_ffi_value($zero_val);
unsafe { [< __pb_rust_Map_ $key_t _ $t _remove >](m, ffi_key, &mut ffi_value) }
@ -459,11 +442,11 @@ fn ptrlen_to_str<'msg>(val: PtrAndLen) -> &'msg ProtoStr {
unsafe { ProtoStr::from_utf8_unchecked(val.as_ref()) }
}
macro_rules! impl_map_with_key_ops_for_scalar_values {
($($t:ty, $t_sized:ty, $ffi_t:ty, $to_ffi_key:expr;)*) => {
macro_rules! impl_ProxiedInMapValue_for_key_types {
($($t:ty, $ffi_t:ty, $to_ffi_key:expr;)*) => {
paste! {
$(
impl_scalar_map_with_key_op_for_scalar_values!($t, $t_sized, $ffi_t, $to_ffi_key, [< MapWith $t:camel KeyOps >] for
impl_ProxiedInMapValue_for_non_generated_value_types!($t, $ffi_t, $to_ffi_key, for
f32, f32, identity, identity, 0f32;
f64, f64, identity, identity, 0f64;
i32, i32, identity, identity, 0i32;
@ -478,13 +461,13 @@ macro_rules! impl_map_with_key_ops_for_scalar_values {
}
}
impl_map_with_key_ops_for_scalar_values!(
i32, i32, i32, identity;
u32, u32, u32, identity;
i64, i64, i64, identity;
u64, u64, u64, identity;
bool, bool, bool, identity;
ProtoStr, &ProtoStr, PtrAndLen, str_to_ptrlen;
impl_ProxiedInMapValue_for_key_types!(
i32, i32, identity;
u32, u32, identity;
i64, i64, identity;
u64, u64, identity;
bool, bool, identity;
ProtoStr, PtrAndLen, str_to_ptrlen;
);
#[cfg(test)]

@ -6,14 +6,10 @@
// https://developers.google.com/open-source/licenses/bsd
use crate::{
Mut, MutProxy, ProtoStr, Proxied, SettableValue, View, ViewProxy,
Mut, MutProxy, Proxied, SettableValue, View, ViewProxy,
__internal::Private,
__runtime::{
MapInner, MapWithBoolKeyOps, MapWithI32KeyOps, MapWithI64KeyOps, MapWithProtoStrKeyOps,
MapWithU32KeyOps, MapWithU64KeyOps,
},
__runtime::{MapInner, ProxiedInMapValue},
};
use paste::paste;
use std::marker::PhantomData;
#[repr(transparent)]
@ -83,122 +79,80 @@ impl<'msg, K: ?Sized, V: ?Sized> std::ops::Deref for MapMut<'msg, K, V> {
// `MapView` (`View<'_, Map>>) and `MapMut` (Mut<'_, Map>).
pub struct Map<K: ?Sized, V: ?Sized>(PhantomData<K>, PhantomData<V>);
macro_rules! impl_proxied_for_map_keys {
($(key_type $t:ty;)*) => {
paste! { $(
impl<V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized> Proxied for Map<$t, V>{
type View<'msg> = MapView<'msg, $t, V> where V: 'msg;
type Mut<'msg> = MapMut<'msg, $t, V> where V: 'msg;
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> SettableValue<Map<$t, V>> for MapView<'msg, $t, V> {
fn set_on<'b>(self, _private: Private, mut mutator: Mut<'b, Map<$t, V>>)
where
Map<$t, V>: 'b {
mutator.copy_from(self);
}
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> ViewProxy<'msg> for MapView<'msg, $t, V> {
type Proxied = Map<$t, V>;
fn as_view(&self) -> View<'_, Self::Proxied> {
*self
}
fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
where 'msg: 'shorter,
{
MapView { inner: self.inner }
}
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> ViewProxy<'msg> for MapMut<'msg, $t, V> {
type Proxied = Map<$t, V>;
impl<K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> Proxied for Map<K, V> {
type View<'msg> = MapView<'msg, K, V> where K: 'msg, V: 'msg;
type Mut<'msg> = MapMut<'msg, K, V> where K: 'msg, V: 'msg;
}
fn as_view(&self) -> View<'_, Self::Proxied> {
**self
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> SettableValue<Map<K, V>>
for MapView<'msg, K, V>
{
fn set_on<'b>(self, _private: Private, mut mutator: Mut<'b, Map<K, V>>)
where
Map<K, V>: 'b,
{
mutator.copy_from(self);
}
}
fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
where 'msg: 'shorter,
{
*self.into_mut::<'shorter>()
}
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> ViewProxy<'msg>
for MapView<'msg, K, V>
{
type Proxied = Map<K, V>;
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MutProxy<'msg> for MapMut<'msg, $t, V> {
fn as_mut(&mut self) -> Mut<'_, Self::Proxied> {
MapMut { inner: self.inner }
}
fn as_view(&self) -> View<'_, Self::Proxied> {
*self
}
fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied>
where 'msg: 'shorter,
{
MapMut { inner: self.inner }
}
}
)* }
}
fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
where
'msg: 'shorter,
{
MapView { inner: self.inner }
}
}
impl_proxied_for_map_keys!(
key_type i32;
key_type u32;
key_type i64;
key_type u64;
key_type bool;
key_type ProtoStr;
);
macro_rules! impl_scalar_map_keys {
($(key_type $t:ty;)*) => {
paste! { $(
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MapView<'msg, $t, V> {
pub fn get<'b>(&self, key: $t) -> Option<View<'b, V>> {
self.inner.get(key)
}
pub fn len(&self) -> usize {
self.inner.size()
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> ViewProxy<'msg>
for MapMut<'msg, K, V>
{
type Proxied = Map<K, V>;
impl<'msg, V: [< MapWith $t:camel KeyOps >] + Proxied + ?Sized + 'msg> MapMut<'msg, $t, V> {
pub fn insert(&mut self, key: $t, value: View<'_, V>) -> bool {
self.inner.insert(key, value)
}
fn as_view(&self) -> View<'_, Self::Proxied> {
**self
}
pub fn remove<'b>(&mut self, key: $t) -> bool {
self.inner.remove(key)
}
fn into_view<'shorter>(self) -> View<'shorter, Self::Proxied>
where
'msg: 'shorter,
{
*self.into_mut::<'shorter>()
}
}
pub fn clear(&mut self) {
self.inner.clear()
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> MutProxy<'msg>
for MapMut<'msg, K, V>
{
fn as_mut(&mut self) -> Mut<'_, Self::Proxied> {
MapMut { inner: self.inner }
}
pub fn copy_from(&mut self, _src: MapView<'_, $t, V>) {
todo!("implement b/28530933");
}
}
)* }
};
fn into_mut<'shorter>(self) -> Mut<'shorter, Self::Proxied>
where
'msg: 'shorter,
{
MapMut { inner: self.inner }
}
}
impl_scalar_map_keys!(
key_type i32;
key_type u32;
key_type i64;
key_type u64;
key_type bool;
);
impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapView<'msg, ProtoStr, V> {
pub fn get(&self, key: impl Into<&'msg ProtoStr>) -> Option<View<'_, V>> {
impl<'msg, K, V> MapView<'msg, K, V>
where
K: Proxied + ?Sized + 'msg,
V: ProxiedInMapValue<K> + ?Sized + 'msg,
{
pub fn get<'a>(&self, key: impl Into<View<'a, K>>) -> Option<View<'msg, V>>
where
K: 'a,
{
self.inner.get(key.into())
}
@ -211,12 +165,27 @@ impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapView<'msg, Pro
}
}
impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapMut<'msg, ProtoStr, V> {
pub fn insert(&mut self, key: impl Into<&'msg ProtoStr>, value: View<'_, V>) -> bool {
self.inner.insert(key.into(), value)
impl<'msg, K, V> MapMut<'msg, K, V>
where
K: Proxied + ?Sized + 'msg,
V: ProxiedInMapValue<K> + ?Sized + 'msg,
{
pub fn insert<'a, 'b>(
&mut self,
key: impl Into<View<'a, K>>,
value: impl Into<View<'b, V>>,
) -> bool
where
K: 'a,
V: 'b,
{
self.inner.insert(key.into(), value.into())
}
pub fn remove(&mut self, key: impl Into<&'msg ProtoStr>) -> bool {
pub fn remove<'a>(&mut self, key: impl Into<View<'a, K>>) -> bool
where
K: 'a,
{
self.inner.remove(key.into())
}
@ -224,7 +193,14 @@ impl<'msg, V: MapWithProtoStrKeyOps + Proxied + ?Sized + 'msg> MapMut<'msg, Prot
self.inner.clear()
}
pub fn copy_from(&mut self, _src: MapView<'_, ProtoStr, V>) {
pub fn get<'a>(&self, key: impl Into<View<'a, K>>) -> Option<View<V>>
where
K: 'a,
{
self.as_view().get(key)
}
pub fn copy_from(&mut self, _src: MapView<'_, K, V>) {
todo!("implement b/28530933");
}
}
@ -239,6 +215,8 @@ mod tests {
fn test_proxied_scalar() {
let mut map_mut = MapMut::from_inner(Private, new_map_i32_i64());
map_mut.insert(1, 2);
assert_that!(map_mut.get(1), eq(Some(2)));
let map_view_1 = map_mut.as_view();
assert_that!(map_view_1.len(), eq(1));
assert_that!(map_view_1.get(1), eq(Some(2)));
@ -261,13 +239,13 @@ mod tests {
#[test]
fn test_proxied_str() {
let mut map_mut = MapMut::from_inner(Private, new_map_str_str());
map_mut.insert("a", "b".into());
map_mut.insert("a", "b");
let map_view_1 = map_mut.as_view();
assert_that!(map_view_1.len(), eq(1));
assert_that!(map_view_1.get("a").unwrap(), eq("b"));
map_mut.insert("c", "d".into());
map_mut.insert("c", "d");
let map_view_2 = map_mut.into_view();
assert_that!(map_view_2.len(), eq(2));

@ -45,8 +45,8 @@ generate_map_primitives_tests!(
#[test]
fn test_string_maps() {
let mut msg = TestMap::new();
msg.map_string_string_mut().insert("hello", "world".into());
msg.map_string_string_mut().insert("fizz", "buzz".into());
msg.map_string_string_mut().insert("hello", "world");
msg.map_string_string_mut().insert("fizz", "buzz");
assert_that!(msg.map_string_string().len(), eq(2));
assert_that!(msg.map_string_string().get("fizz").unwrap(), eq("buzz"));
assert_that!(msg.map_string_string().get("not found"), eq(None));

@ -578,77 +578,62 @@ impl<'msg, K: ?Sized, V: ?Sized> Clone for MapInner<'msg, K, V> {
}
}
macro_rules! generate_map_key_ops_traits {
($($t:ty, $sized_t:ty;)*) => {
paste! {
$(
pub trait [< MapWith $t:camel KeyOps >] : Proxied {
fn new_map(a: RawArena) -> RawMap;
fn clear(m: RawMap) {
unsafe { upb_Map_Clear(m) }
}
fn size(m: RawMap) -> usize {
unsafe { upb_Map_Size(m) }
}
fn insert(m: RawMap, a: RawArena, key: $sized_t, value: View<'_, Self>) -> bool;
fn get<'msg>(m: RawMap, key: $sized_t) -> Option<View<'msg, Self>>;
fn remove(m: RawMap, key: $sized_t) -> bool;
}
impl<'msg, V: [< MapWith $t:camel KeyOps >] + ?Sized> MapInner<'msg, $t, V> {
pub fn new(arena: &'msg mut Arena) -> Self {
MapInner {
raw: V::new_map(arena.raw()),
arena,
_phantom_key: PhantomData,
_phantom_value: PhantomData
}
}
pub trait ProxiedInMapValue<K>: Proxied
where
K: Proxied + ?Sized,
{
fn new_map(a: RawArena) -> RawMap;
fn clear(m: RawMap) {
unsafe { upb_Map_Clear(m) }
}
fn size(m: RawMap) -> usize {
unsafe { upb_Map_Size(m) }
}
fn insert(m: RawMap, a: RawArena, key: View<'_, K>, value: View<'_, Self>) -> bool;
fn get<'a>(m: RawMap, key: View<'_, K>) -> Option<View<'a, Self>>;
fn remove(m: RawMap, key: View<'_, K>) -> bool;
}
impl<'msg, K: Proxied + ?Sized, V: ProxiedInMapValue<K> + ?Sized> MapInner<'msg, K, V> {
pub fn new(arena: &'msg mut Arena) -> Self {
MapInner {
raw: V::new_map(arena.raw()),
arena,
_phantom_key: PhantomData,
_phantom_value: PhantomData,
}
}
pub fn size(&self) -> usize {
V::size(self.raw)
}
pub fn size(&self) -> usize {
V::size(self.raw)
}
pub fn clear(&mut self) {
V::clear(self.raw)
}
pub fn clear(&mut self) {
V::clear(self.raw)
}
pub fn get<'a>(&self, key: $sized_t) -> Option<View<'a, V>> {
V::get(self.raw, key)
}
pub fn get<'a>(&self, key: View<'_, K>) -> Option<View<'a, V>> {
V::get(self.raw, key)
}
pub fn remove(&mut self, key: $sized_t) -> bool {
V::remove(self.raw, key)
}
pub fn remove(&mut self, key: View<'_, K>) -> bool {
V::remove(self.raw, key)
}
pub fn insert(&mut self, key: $sized_t, value: View<'_, V>) -> bool {
V::insert(self.raw, self.arena.raw(), key, value)
}
}
)*
}
pub fn insert(&mut self, key: View<'_, K>, value: View<'_, V>) -> bool {
V::insert(self.raw, self.arena.raw(), key, value)
}
}
generate_map_key_ops_traits!(
i32, i32;
u32, u32;
i64, i64;
u64, u64;
bool, bool;
ProtoStr, &ProtoStr;
);
macro_rules! impl_scalar_map_key_op_for_scalar_values {
($key_t:ty, $key_msg_val:expr, $key_upb_tag:expr, $trait:ident for $($t:ty, $msg_val:expr, $from_msg_val:expr, $upb_tag:expr, $zero_val:literal;)*) => {
macro_rules! impl_ProxiedInMapValue_for_non_generated_value_types {
($key_t:ty, $key_msg_val:expr, $key_upb_tag:expr, for $($t:ty, $msg_val:expr, $from_msg_val:expr, $upb_tag:expr, $zero_val:literal;)*) => {
$(
impl $trait for $t {
impl ProxiedInMapValue<$key_t> for $t {
fn new_map(a: RawArena) -> RawMap {
unsafe { upb_Map_New(a, $key_upb_tag, $upb_tag) }
}
fn insert(m: RawMap, a: RawArena, key: $key_t, value: View<'_, Self>) -> bool {
fn insert(m: RawMap, a: RawArena, key: View<'_, $key_t>, value: View<'_, Self>) -> bool {
unsafe {
upb_Map_Set(
m,
@ -659,7 +644,7 @@ macro_rules! impl_scalar_map_key_op_for_scalar_values {
}
}
fn get<'msg>(m: RawMap, key: $key_t) -> Option<View<'msg, Self>> {
fn get<'a>(m: RawMap, key: View<'_, $key_t>) -> Option<View<'a, Self>> {
let mut val = $msg_val($zero_val);
let found = unsafe {
upb_Map_Get(m, $key_msg_val(key), &mut val)
@ -670,7 +655,7 @@ macro_rules! impl_scalar_map_key_op_for_scalar_values {
Some($from_msg_val(val))
}
fn remove(m: RawMap, key: $key_t) -> bool {
fn remove(m: RawMap, key: View<'_, $key_t>) -> bool {
let mut val = $msg_val($zero_val);
unsafe {
upb_Map_Delete(m, $key_msg_val(key), &mut val)
@ -701,11 +686,11 @@ fn msg_to_str<'msg>(msg: upb_MessageValue) -> &'msg ProtoStr {
unsafe { ProtoStr::from_utf8_unchecked(msg.str_val.as_ref()) }
}
macro_rules! impl_map_key_ops_for_scalar_values {
macro_rules! impl_ProxiedInMapValue_for_key_types {
($($t:ty, $t_sized:ty, $key_msg_val:expr, $upb_tag:expr;)*) => {
paste! {
$(
impl_scalar_map_key_op_for_scalar_values!($t_sized, $key_msg_val, $upb_tag, [< MapWith $t:camel KeyOps >] for
impl_ProxiedInMapValue_for_non_generated_value_types!($t, $key_msg_val, $upb_tag, for
f32, scalar_to_msg!(float_val), scalar_from_msg!(float_val), UpbCType::Float, 0f32;
f64, scalar_to_msg!(double_val), scalar_from_msg!(double_val), UpbCType::Double, 0f64;
i32, scalar_to_msg!(int32_val), scalar_from_msg!(int32_val), UpbCType::Int32, 0i32;
@ -720,7 +705,7 @@ macro_rules! impl_map_key_ops_for_scalar_values {
}
}
impl_map_key_ops_for_scalar_values!(
impl_ProxiedInMapValue_for_key_types!(
i32, i32, scalar_to_msg!(int32_val), UpbCType::Int32;
u32, u32, scalar_to_msg!(uint32_val), UpbCType::UInt32;
i64, i64, scalar_to_msg!(int64_val), UpbCType::Int64;

Loading…
Cancel
Save