From 9b80236f88b84ef7b7fb9349f21671a200bb96cb Mon Sep 17 00:00:00 2001 From: Sam Huddart Date: Sat, 20 Apr 2024 13:37:02 +0100 Subject: [PATCH 1/3] Update chars.rs --- protobuf/src/chars.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/protobuf/src/chars.rs b/protobuf/src/chars.rs index 9a2109eea..d97e92a89 100644 --- a/protobuf/src/chars.rs +++ b/protobuf/src/chars.rs @@ -4,6 +4,7 @@ use std::borrow::Borrow; use std::fmt; use std::ops::Deref; use std::str; +use std::convert::AsRef; use bytes::Bytes; @@ -81,6 +82,12 @@ impl Borrow for Chars { } } +impl AsRef for Chars { + fn borrow(&self) -> &Bytes { + &self.0 + } +} + impl fmt::Display for Chars { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { From 3aff8c37c633c8cdd0810e29ec5883c553aa9998 Mon Sep 17 00:00:00 2001 From: Sam Huddart Date: Sat, 20 Apr 2024 13:44:32 +0100 Subject: [PATCH 2/3] Update chars.rs --- protobuf/src/chars.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protobuf/src/chars.rs b/protobuf/src/chars.rs index d97e92a89..79af0a243 100644 --- a/protobuf/src/chars.rs +++ b/protobuf/src/chars.rs @@ -83,7 +83,7 @@ impl Borrow for Chars { } impl AsRef for Chars { - fn borrow(&self) -> &Bytes { + fn as_ref(&self) -> &Bytes { &self.0 } } From 22b401059527dc7711140c3a4e12ebf91a92c42b Mon Sep 17 00:00:00 2001 From: Sam Huddart Date: Sat, 20 Apr 2024 13:49:19 +0100 Subject: [PATCH 3/3] added deref to runtime_type.rs --- protobuf/src/reflect/runtime_types.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/protobuf/src/reflect/runtime_types.rs b/protobuf/src/reflect/runtime_types.rs index 26bfe9669..a17d66c68 100644 --- a/protobuf/src/reflect/runtime_types.rs +++ b/protobuf/src/reflect/runtime_types.rs @@ -3,6 +3,7 @@ use std::collections::HashMap; use std::fmt; use std::marker; +use std::ops::Deref; #[cfg(feature = "bytes")] use bytes::Bytes; @@ -738,7 +739,7 @@ impl RuntimeTypeTrait for RuntimeTypeTokioChars { } fn as_ref(value: &Chars) -> ReflectValueRef { - ReflectValueRef::String(value.as_ref()) + ReflectValueRef::String(::deref(value)) } fn is_non_zero(value: &Chars) -> bool {