Rust
https://www.rust-lang.org/
Notes
Ownership
There are three rules to ownership in Rust:
Each value has an owner
There is only one owner of a value - other variables may borrow the value
When the owner of a value goes out of scope, the value gets dropped immediately
In Rust, we use the term copy when only stack variables are copied; if there is heap data as well we use the term clone
When a value is dropped:
the destructor, if available, is immediately run
the heap portion is immediately freed
the stack portion is immediately popped
References & Borrowing
A reference to a type is specified using the
&
(ampersand) notationRust introduces a concept called lifetimes, which can be summed up as the rule that references must always be valid, which means the compiler will not allow you to create a reference that outlives the value it is referencing, and you can never point to null
References are immutable by default, but can be changed to mutale using the
&mut
notationAt any given time, you can have either exactly one mutable reference or any numer of immutable references to a value
Resources
Articles
Books
Crates
Courses
GitHub repositories
IDEs
Libraries
Subreddits
Websites
YouTube channels
YouTube playlists
Rust for Java Developers - Jeremy Chone
Last updated
Was this helpful?