How to Avoid Fighting Rust Borrow Checker
The 3 important facts in Rust:
Tree-shaped ownership. In Rust's ownership system, one object can own many children or no chlld, but must be owned by exactly one parent. Ownership relations form a tree. 1
Mutable borrow exclusiveness. If there exists one mutable borrow for an object, then no other borrow to that object can exist. Mutable borrow is exclusive.
Borrow is contagious (if crossing function boundary). If you borrow a child, you indirectly borrow the parent (and parent's parent, and so o...
Read more at qouteall.github.io