fdeantoni / prost-wkt

Prost Well-Known-Types serialization and deserialization.
Apache License 2.0
76 stars 35 forks source link

Change parameter of `try_pack` from `T` to `&T` #48

Open ik1ne opened 1 year ago

ik1ne commented 1 year ago

Any::try_pack takes message: T as parameter, consuming it. However, taking message: &T instead of message: T would work too, allowing the callers to reuse message.

fdeantoni commented 1 year ago

Good point. Let me check if this can simply be added as well.

Sushisource commented 1 year ago

Same for unpack. A common pattern would be to try to unpack as a series of different types, but taking self by ownership prevents this and forces you to explicitly check the type url first.

AFAICT it's a trivial change, since self never actually needs to get consumed in the unpacking functions.