Oh, yeah… this is a question about an “ownership”.
What parts of the code may/can modify some underlying data?..
What parts of the code should allocate on the heap and which one should/must free()
?..
aside note: IMHO, rust-lang approach to these really (in general) hard issues to handle
is a bit “schizophrenic”:
- at hardware level we have
- physical memory cells in some data storage device
- a state of that cells - it is a “value” of those memory cells
Note, that a physical memory cell can not exits apart of it’s content (“a value”)
- at a programming language level we have
- a variable name
- and a “value”, assotiated with that exact name
Note again - one “variable” - one “value”, they can not exist apart, as some independent “entities”.
What rust-lang (the sooper-pooper, yeah) is doing with all that weird “ownership” conception?
It tries to separate a physical storage and it’s content (“who owns a value?”)
It is schizophrenic way of thinking, isn’t it?
My terms/words are probably was not the best in the post,
but let it be as is…