Ownership Based Resource Management
OBRM
, also known as RAII
means 'Resoure Acquisition is Initialization'. Roughly speaking, to acquire a resource, you need to create an object that manages it.
Constructors
Unlike C++, Rust doesn't have a built-in kinds of constructor. Rust requires explicit calls to create/destroy the object.
Move constructor
Copy
and Clone
trait provides C++'s copy-oriented semantics. Copy
types are implicitly cloned whenever they're moved.
Destructors
fn drop(&mut self)
After drop
is run, Rust will recursively drop all of the fields.