Skip to content

Commit

Permalink
generalize compact
Browse files Browse the repository at this point in the history
  • Loading branch information
gui1117 committed Jan 18, 2019
1 parent 07c93ac commit f4d8911
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion derive/src/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn create_decode_expr(field: &Field, input: &TokenStream) -> TokenStream {
if compact {
let field_type = &field.ty;
quote_spanned! { field.span() =>
<_parity_codec::Compact<#field_type> as _parity_codec::Decode>::decode(#input)?.into()
<<#field_type as _parity_codec::HasCompact>::Type as _parity_codec::Decode>::decode(#input)?.into()
}
} else if let Some(encoded_as) = encoded_as {
quote_spanned! { field.span() =>
Expand Down
7 changes: 6 additions & 1 deletion derive/src/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ fn encode_fields<F>(
if compact {
let field_type = &f.ty;
quote_spanned! {
f.span() => { #dest.push(&_parity_codec::Compact::<#field_type>::from(#field)); }
f.span() => {
#dest.push(
&<<#field_type as _parity_codec::HasCompact>::Type as
_parity_codec::EncodeAsRef<#field_type>>::RefType::from(#field)
);
}
}
} else if let Some(encoded_as) = encoded_as {
let field_type = &f.ty;
Expand Down

0 comments on commit f4d8911

Please sign in to comment.