Rust Ownership 4: References and Borrowing

In part 3 of this series, we learned what Ownership in Rust means and some of the ways ownership of a value can be transferred (moved). We also learned about the Borrow-Checker and how it prevents us from illegally accessing data in Rust. We also came to the conclusion that it would be tedious if we could never use a variable again after passing it into a function (because ownership has been moved), and I said that Rust allows us to borrow values rather than take up their ownership. ...

January 13, 2024

Rust Ownership 3: The Borrow Checker, Scope, and Ownership

This is the third article in the Rust Ownership Series. In part 1 and part 2, we learned the following basic concepts: Value Types, Reference Types, Memory Management, Stack and Heap Memory. These concepts are the building blocks that will make it easier to understand Ownership in Rust. In part 3 of the series, we will be learning about the Borrow-Checker, Scope, and Ownership - alongside the rules of Ownership. Understanding these concepts will make your journey into Rust programming a lot easier. This article has a lot of visualizations to make the concepts click faster, enjoy the ride :) ...

December 12, 2023

Rust Ownership 2: Understanding Stack and Heap Memory

In the first article in this series, we laid some foundational groundwork by learning about Value and Reference types. We also learned about how Computer Memory works at a high level. I recommend that you read the article if you haven’t before continuing. In this article, we continue from where we left off and learn about Stack and Heap Memory. We will work through some code examples in Rust, with visualizations to make the concepts stick. Understanding Stack and Heap memory is fundamental to the ultimate goal, which is to learn what Ownership is in Rust and how it works. ...

November 16, 2023

Rust Ownership 1: Value and Reference Types Explained In Rust

Rust is a system programming language known for its focus on memory safety; ownership is a fundamental concept that sets it apart from other programming languages. As someone coming from a JavaScript, TypeScript, and Go background, the concept of ownership was very hard for me to grasp. It’s one of the things that sets Rust apart from any other language. Ownership is a set of rules that govern how Rust programs manage memory. Rust’s ownership system is designed to prevent common memory-related bugs such as null pointer dereferencing, use-after-free errors, and data races. ...

November 10, 2023