Hacker News new | ask | show | jobs
by carlmr 1723 days ago
You can easily avoid such constructs in most cases though.
1 comments

I've allocated both these things on the heap and Rust simply won't let me store them both together. I don't know about you but this is an extremely common pattern in almost all languages, you just don't think about it in the gc languages and in C++ storing pointers is no issue. The popularity of crates like rental also shows that it's not as easily avoidable as you suggest.
Can you post a simple code example? It is hard to imagine what the difficulty is.
You can read through this SO question and the top response does a good job explaining the possible solutions: https://stackoverflow.com/questions/32300132/why-cant-i-stor...
Seems like using Box solves this issue fairly simply.