I have asked a couple of questions here relating to the heap and with all the answers I get I am not sure what is the importance of making a distinction of heap in Rust.
To explain where I am coming from. I have mostly developed in Java, and there is a clear case for what goes on the stack and what goes on the heap. For example if there is a primitive version of a type, it is advisable to use that (since this will be on the stack) instead of using one that will create an object (which will go on the heap and be work for the garbage collector)
So there is a clear distinction of what goes to the heap and what goes to the stack in everyday programming.
But in Rust this does not seem to be the case.
In Is Clone for copying on the heap, while Copy for copying on the stack in Rust? I was made to understand that Copy/Clone is not dependent on Stack/Heap. My initial wrong impression was, cloning occurs only with value on the heap (I think this also comes from my Java background, where cloning applies to objects and those are values that live on the heap)
Then in Are Dynamically Sized Typed always on the heap? I was also made to know that DSTs can exist both on the heap and also on the stack.
So right now I am not sure of the importance of having this distinction between memory regions in Rust. Because it seems things that can be done on one can be done on the other. And values that can be place on one can also be placed on the other.
What am I missing? And what is the practical repercussion of these two memory regions in Rust. By practical repercussion, I am thinking of distinct properties that is only possible with one region and not with the other.