[Question][Textbook problems]Learning Rust Ownership and practice questions.
from InternetCitizen2@lemmy.world to rust@programming.dev on 25 Mar 00:50
https://lemmy.world/post/13508677

Hello All:

I am working on rust problems here. In the second question I solved it by simply adding the return statement for the function to modify. I am not sure what the lesson in ownership to walk away with in this problem. Any guidance?

#rust

threaded - newest

fil@programming.dev on 25 Mar 02:02 collapse

By adding the return statement you pass the ownership of the string back to main. The unmodified function just took the ownership of the string and deallocated it after printing. Hope this helps

InternetCitizen2@lemmy.world on 25 Mar 02:57 collapse

Yeah thanks!