mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
proc_macro: support encoding/decoding structs with type parameters
This commit is contained in:
parent
2d1e075079
commit
7678e6ad85
@ -43,15 +43,17 @@ macro_rules! rpc_encode_decode {
|
||||
}
|
||||
}
|
||||
};
|
||||
(struct $name:ident { $($field:ident),* $(,)? }) => {
|
||||
impl<S> Encode<S> for $name {
|
||||
(struct $name:ident $(<$($T:ident),+>)? { $($field:ident),* $(,)? }) => {
|
||||
impl<S, $($($T: Encode<S>),+)?> Encode<S> for $name $(<$($T),+>)? {
|
||||
fn encode(self, w: &mut Writer, s: &mut S) {
|
||||
$(self.$field.encode(w, s);)*
|
||||
}
|
||||
}
|
||||
|
||||
impl<S> DecodeMut<'_, '_, S> for $name {
|
||||
fn decode(r: &mut Reader<'_>, s: &mut S) -> Self {
|
||||
impl<'a, S, $($($T: for<'s> DecodeMut<'a, 's, S>),+)?> DecodeMut<'a, '_, S>
|
||||
for $name $(<$($T),+>)?
|
||||
{
|
||||
fn decode(r: &mut Reader<'a>, s: &mut S) -> Self {
|
||||
$name {
|
||||
$($field: DecodeMut::decode(r, s)),*
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user