Rust Borrowing Rule

Rust Borrowing Rule states that there can be either multiple immutable references or only one mutable reference at the same time. If such rule is violated, depending on the situation, the compiler will throw a compilation error or the program will panic during the runtime and crash itself instead (this is the case for #202206232210).

Links to this page
  • Rust Smart Pointers
    202206232210# where the 202206241126# is checked in runtime instead
  • Rust RefCell

    RefCell<T> (import it from std::cell::RefCell) is a kind of #202111301656 that implements single ownership but allows interior mutability which permits the mutation of data on immutable references. Unlike 202206221113 and 202206221720, it checks the 202206241126# in runtime rather in compile time. This means that instead of showing up as a compilation error, the program will still be able to be compiled but panic and exit if there is a violation of the borrowing rule.

#rust #resource