logoalt Hacker News

LukaDyesterday at 11:38 PM1 replyview on HN

You don't need Box here because Vec<T> is already a fixed size handle to heap data.


Replies

slaymaker1907today at 12:55 AM

A vector of boxes is beneficial if you need to move objects around. If each T is 1000B or something, you really don’t want to copy or even do true moves in memory.

Hell, even if you’re not moving things around explicitly, don’t forget that vectors resize themselves. If you use Box, then these resizes will be less painful with large objects.

show 1 reply