Ownership

Rust's memory manage

Rust Ownership Concept

Rust has a very unique style of managing memory. Rust uses something called Ownership to manage memory. Unlike other languages like Java or Go-lang which use Garbage collection program, rust relies on Ownership concept.

Ownership Rules

Rust has three ownership rules that one must always remember

  1. Each variable has something called Owner

  2. There can only be ONE Owner at a given time for a variable

  3. If the Owner goes out of the scope the value will be dropped

That's it, this sounds very simple however, while coding and following the rule, this could be one of the most toughest to conquer (apart from Lifetimes which we will discuss later)

Last updated

Was this helpful?