I think I've *finally* wrapped my head around the basic ownership and borrowing rules in #Rust. I put together a quick demo here: https://gist.github.com/ShawnHymel/ecbdb3a311d55f420af8bda05defa273. I know there are some esoteric rules I likely missed, but these should be the major ones. Let me know if I missed something! #programming #embedded
Rust ownership and borrowing rules demonstration

Rust ownership and borrowing rules demonstration. GitHub Gist: instantly share code, notes, and snippets.

Gist
@shawnhymel looks a lot like c++11 unique_ptr and shared_ptr !
@mat_kelcey Agreed. Modern C++ introduced a lot of ways to be more memory-safety cognizant with things like smart pointers. I generally enjoy them. Rust's ownership model is a little different--the idea of a shared_ptr doesn't exist (outside of unsafe blocks) due to the "one owner" rule.