Skip to content

Comment on Box to save memory in Rust

Comments

This is an interesting concept. I was initially thinking that this would only lower the memory usage of the stack by moving everything to the heap, but of course you can skip heap allocation if the struct you'd be instantiating is "empty". The stack doesn't really have that luxury since the compiler needs to guarantee that there's space on the stack for the value, if it were to be initialized.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.