BeautyyuYanli / gitalk-for-blog

gitalk-for-blog
0 stars 0 forks source link

Rust: A Generally View of Reference and Its Mutability #14

Open BeautyyuYanli opened 1 year ago

BeautyyuYanli commented 1 year ago

https://blog.beautyyu.one/rust-a-general-view-of-reference-and-its-mutability

Rust's most important idea is the "owner" model. This helps us manage data in memory so we don't get memory leaks or double-free errors. A reference (&) is used to access or change data without taking responsibility for it. This is more like a pointer in C/C++ than a reference in C++. In Rust, a reference is usually not changeable, but it can be made changeable at the top or bottom level. Automatic dereferencing is used to work out if a reference should act like an alias or a pointer.