Skip to content

Commit 674525c

Browse files
committed
proc_macro: support encoding/decoding structs with type parameters
1 parent ce331ee commit 674525c

File tree

1 file changed

+6
-4
lines changed
  • library/proc_macro/src/bridge

1 file changed

+6
-4
lines changed

library/proc_macro/src/bridge/rpc.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,17 @@ macro_rules! rpc_encode_decode {
4343
}
4444
}
4545
};
46-
(struct $name:ident { $($field:ident),* $(,)? }) => {
47-
impl<S> Encode<S> for $name {
46+
(struct $name:ident $(<$($T:ident),+>)? { $($field:ident),* $(,)? }) => {
47+
impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)? {
4848
fn encode(self, w: &mut Writer, s: &mut S) {
4949
$(self.$field.encode(w, s);)*
5050
}
5151
}
5252

53-
impl<S> DecodeMut<'_, '_, S> for $name {
54-
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
53+
impl<S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S>
54+
for $name $(<$($T),+>)?
55+
{
56+
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
5557
$name {
5658
$($field: DecodeMut::decode(r, s)),*
5759
}

0 commit comments

Comments
 (0)