4 ms·
The String and Vec objects live on the stack in the same way, but they contain pointers to heap data. I think the grandparent was trying to get at the fact that
by dbaupp 9y ago
The String and Vec objects live on the stack in the same way, but they contain pointers to heap data. I think the grandparent was trying to get at the fact that &str etc don't force things onto the heap nor do they keep things on the heap alive.
- saghm 9y agoYep, from looking at all the comments in response in my original comment, it seems like I didn't do a great job explaining what I meant here; the basic idea is that if I'm trying to optimize my program by minimizing heap allocations, I can safely ignore any instances of &str, &[T], etc. and just focus on String, Vec, etc.