prost-wkt icon indicating copy to clipboard operation
prost-wkt copied to clipboard

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

Open ik1ne opened this issue 2 years ago • 2 comments

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.

ik1ne avatar Aug 21 '23 03:08 ik1ne

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

fdeantoni avatar Sep 19 '23 20:09 fdeantoni

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.

Sushisource avatar Sep 27 '23 21:09 Sushisource