foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Use #[derive(RlpEncodableWrapper, RlpDecodableWrapper)]

Open foriequal0 opened this issue 6 years ago • 2 comments

struct StructWithSingleField<T> {
    field: T
}

impl<T: Encodable> Encodable for StructWithSingleField<T> {
    fn rlp_append(&self, s: &mut RlpStream) {
        self.field.rlp_append(s);
    }
}

can be simplified to

#[derive(RlpEncodableWrapper)]
struct StructWithSingleField<T> {
    field: T
}

It can be applied to struct StructWithSingleTuple<T>(T), and RlpDecodable too.

foriequal0 avatar Jan 23 '19 07:01 foriequal0

I searched with the keyword impl Encodable but there was no such results. I think this issue was isolated a long time ago.

HoOngEe avatar Nov 08 '19 12:11 HoOngEe

I found that the Encodable implementation for SignedMessage can use the RlpEncodableWrapper.

majecty avatar Dec 26 '19 06:12 majecty