News for hackers. Stuff that matters.
Re:Effective Rust by umanwizard on Thursday June 15, 2023 @09:05AM (#36339880)
> Needlessly allocates a `Vec` if `self.payload` is `Some`.

Empty vecs don’t require a heap allocation, so your original code is actually fine. In release mode it should compile to exactly the same instructions as your last example.

There are no comments on this comment yet.