I have seen this question, but still didn't get it, so here's what I know (it might be incorrect):
- Initializing a variable of type
String
allocates memory on the heap and stores a pointer to that memory on the stack. - Initializing a variable of type
&str
stores a pointer on the stack, and I'm assuming that pointer points to astr
on the heap.
If that's the case - if both String
and &str
store pointers on the stack pointing to memory locations on the heap - does that mean String
and str
(not the reference) are the same?