Rust for Dummies in 12 Minutes

The Only Bamboo
246 followers
13 Video Views·Feb 2, 2026
0:00 Introduction: Why Learn Rust and What This Video Covers
0:55 Part 1: How Rust Prevents Memory Safety Bugs with Ownership and Borrowing
7:07 Part 2: The Power of Rust’s Type System in Preventing Logical and Runtime Errors
11:08 Closing: Introducing the Rust Live Accelerator and Call to Join the Waitlist
There's one thing all these languages have in common, they suck.
So you should learn Rust, but learning Rust is like trying to get a Ph.D. in compiler
theory while getting kicked in the butt repeatedly, unless you have a clear guide that maps all
the features you already know and love from other languages to Rust.
Welcome to Rust for Dummies, where I'll explain all the confusing Rust concepts you
need to know to be an effective Rust developer in terms that even a JavaScript developer
will understand.
By the end, you'll not only get Rust, you'll start preaching Rust to all your coworkers
unsolicited like a true Rustation.
This video is part of a series for the upcoming official launch of my Rust Live Accelerator,
the all-in-one Rust Live training program designed to help you land your first Rust
job and become a high-performing Rust developer.
The exact official launch date will be announced very soon.
To join the waitlist, pause this video right now and visit letsgetrusty.com slash join.
Part 1.
Why Rust Code Doesn't Break You know those bugs that only show up in
production?
Seg faults, data corruption, mysterious system crashes?
Rust eliminates those.
At compile time, no garbage collector, no performance hit.
But how does Rust achieve this?
A C or C++ developer's biggest nightmare is double-free or use-after-free errors, which
can cause your entire program to crash, or worse, corrupt data silently.
A double-free occurs when you deallocate the same memory twice, which can corrupt the heap.
And a use-after-free happens when memory is accessed after it's been freed, leading to
undefined behavior.
The problem is manually freeing memory is extremely error-prone.
In contrast, higher-level languages prevent manual memory management bugs by introducing
a garbage collector.
This is an added background process that automatically frees memory after it's no longer used.
This seems convenient, but garbage collectors are notorious for causing intermittent performance
issues at runtime, as a garbage collector may pause one or more threads to reclaim memory.
This is the type of unpredictable performance hit a system's programming language simply
cannot afford.
Luckily, Rust has a compile-time solution to deal with memory management without incurring
any runtime overhead, a brilliant system called the ownership model.
In Rust, each value has a single owner.
In this case, the user1 variable owns a user instance, and controls the lifecycle of the
value.
When user1 goes out of scope, the value will be automatically dropped, all predetermined
at compile time.
But what happens when you reassign the value from user1 to user2, for example, or even
pass the value into a function?
Who ends up owning the value?
In this example, the ownership of the underlying value gets transferred first from user1 to
user2, and then from user2 to user3.
And lastly, the user value gets dropped at the end of the function when user3 goes out
of scope.
Once ownership moves, the previous variable no longer claims the ownership of the underlying
value, and it can no longer access the value either.
This transfer of ownership is called move semantics, and it's really important because
it eliminates nasty memory bugs like double-free and use-after-free, which we saw in the C
and C++ example before.
So ownership and move semantics solve the problem of allocating and deallocating memory
without manual memory management or a garbage collector.
But ownership is only a piece of the puzzle.
Sometimes you don't want to move or transfer the ownership of a value.
For example, let's say we wanted to call printName twice.
In this case, attempting to call printName the second time is not allowed, because the
ownership of the underlying user value has already been passed to the user3 argument
inside the printName function during the first call to printName.
What we really want is to give the printName function temporary access to the user instance
while the user2 variable still maintains the ownership.
In most other languages, you can hand out temporary access to a value by passing around
references or pointers to the value.
But the problem with references and pointers is they allow you to do dangerous, dumb, and
terrible things like reading and writing to the same value at the same time, mutating
shared state without realizing it, or dereferencing a null pointer.
The gist is, these languages allow you to do dangerous things with references and pointers.
That's how you get weird side effects, data races, and all types of bugs that only show
up in production.
The good news is, Rust has a clever solution for this as well, called the Borrowing Model.
Rust allows you to gain temporary access to a value using references with a twist.
Unlike other languages, references in Rust have certain rules to make sure you don't
shoot yourself in the foot.
First of all, Rust distinguishes between immutable references and mutable references.
Let's go back to our previous ownership example.
If we update the printName function to take an immutable reference to the user instance,
our code will compile.
We can also add an updateName function and have it take a reference.
But this time our code doesn't compile because we are trying to mutate a value behind an
immutable reference.
To fix this, we have to explicitly mark the user2 value as mutable and update the reference
passed to the updateName function to be a mutable reference.
Now our code compiles.
This explicit labeling of mutable references is great because it prevents accidental mutation.
By the way, in the Rust world, a reference is synonymous with a borrow, and referencing
is synonymous with borrowing.
You'll hear both used frequently.
That's why this is called the Borrowing Model.
In our code example, we can say that printName takes an immutable borrow and updateName takes
a mutable borrow.
So that's the first rule of the Borrowing Model.
The second rule is that you can either have one mutable reference or any number of immutable
references at one time.
Rust prevents you from using immutable references while a mutable reference is active.
For example, if we create two variables, one holding a mutable reference to the user instance
and one holding an immutable reference to the user instance, and then pass those references
to printName and updateName, we would get a compile-time error.
The problem is the mutable and immutable borrows overlap.
When we call updateName, an immutable reference to the user instance exists, and is passed
to the printName function on the next line.
This is problematic because the immutable reference is not expecting the underlying
value to change.
The Rust compiler wants to ensure that when you get an immutable reference to a value,
it's guaranteed the value cannot be changed for as long as you hold that immutable reference.
The solution is simple.
We can define our two after the call to updateName, or we can simply inline the references like
the original example.
The third rule is, references must be pointing to valid memory.
The compiler ensures this by checking to see if references are used after the underlying
value has been freed.
References to the user instance are only valid until user1 is dropped.
After the user instance is dropped, references are considered invalid and we would get a
compile-time error if we tried to use them.
This system of borrowing gives us the convenience of temporary access to values without the
Okay, so we talked about how Rust prevents an entire class of memory safety bugs through
the ownership and borrowing model.
But surely, Rust can't prevent logical bugs too, right?
You know, those bugs you create when your brain isn't braining.
Well, actually, it can.
To a large extent.
Let's see how.
Part 2.
The Genius of Rust Type System Imagine you update a dependency.
Some library you're using.
There are no errors, everything compiles so you ship your code and deploy it to the cloud.
But then everything breaks.
In production.
Why?
Because the library author updated a function or removed a side effect, and your compiler
didn't catch any of it.
This happens all the time.
Not because library authors are careless, but because most languages don't give us
the tools to express, and more importantly enforce, constraints through code.
Let's say we're the ones working on the library and writing a user class in Java.
We want to make sure other developers cannot misuse our data structure, so we need to enforce
some constraints.
First, every user is required to have a name.
So our name variable here should never be null.
To enforce that, we import an external library like Lumbok, which provides us with a non-null
annotation.
We also want to make sure null values cannot be passed to our functions.
Next, we want to enforce that our function arguments cannot be mutated within the functions
by marking them with the final keyword.
This prevents accidental mutation and communicates our intent to future developers modifying
this class.
Lastly, we need to handle a special case.
Even though the userProfile function argument passed in is non-null, its member variables
can still be null.
So we want to verify that the displayName field of userProfile is non-null at runtime.
But now we run into another problem.
If the displayName is null at runtime, the non-null check here will throw a nullPointer
exception.
But the callers of the fromUserProfile function have no idea that it can throw by only looking
at the function signature.
So let's add in a java.comment to give callers a warning.
Now the funny thing is nullPointer exceptions in Java are so common that a typical Java
developer probably wouldn't even bother adding a java.comment like this.
So here we have it.
We did all this work just to enforce some basic type constraints and make sure our user
class is used properly.
Now imagine trying to get everyone else at a company to follow these strict guidelines
to prevent misuse of their classes.
Sorry, it ain't gonna happen.
And Java is supposed to be a strongly typed language.
We haven't even mentioned weakly typed languages yet, which are absolute dumpster fires.
Ok now let's see how we would enforce these same constraints in Rust.
Here's how we would write the exact same user object in Rust.
So what would we need to change to prevent null objects, accidental mutation, and unexpected
exceptions?
The answer is nothing.
Rust's type system is safe and robust by default.
For example, in Rust, null simply doesn't exist.
Instead, we have the OptionEnumWrapper, whose value can either be the some variant containing
an object, or the none variant containing no object.
So if we wanted the user's name to be optional, we would have to wrap it in an OptionEnum.
And the compiler will automatically make sure you handle both the none case and the some
case.
Additionally, values in Rust are immutable by default.
If we wanted our function arguments to be mutable, we would have to explicitly mark
them with the mute keyword.
This would let callers of the function know that the values they pass in might be mutated.
Lastly, in Rust, we don't have to worry about exceptions.
Instead, if we want the fromUserProfile function to be able to handle potential failures, we
would update the function signature to return a resultEnumWrapper, whose value could either
be the error variant containing an error object, or the okay variant containing the result.
The beauty here is that function signatures in Rust tell you everything you need to know
about the function.
Does it mutate its arguments?
Are the arguments passed by reference or value?
Does it throw an error?
Everything is explicit and clear, at compile time.
That's why when you write Rust code, you can have high confidence that, if it compiles,
it works.
Now of course, this is only the tip of the iceberg.
To use Rust professionally, you also have to understand advanced features like AsyncRust,
best practices and patterns, how to architect out Rust codebases, and much more.
And you guys have been emailing me and asking me, how do I get good at Rust?
Where do I find Rust jobs?
And how do I get hired as a Rust developer?
So over the last year, I've been working with individual developers to help them master
the language and land Rust jobs.
And after multiple iterations and refinements, we've built a rock-solid training program
that I'm now ready to share with you.
And it's called the Rust Live Accelerator.
In this private group training program, I'll personally work with you to take you from
a beginner all the way to an employed Rust developer.
Using a simple yet effective 3-step roadmap that has worked for dozens of our students.
So if you're serious about using Rust professionally, this program is for you.
We'll start accepting applications soon and we'll only have 25 spots available.
These spots are expected to go fast, so make sure you don't miss your chance to join by
visiting letsgetrusty.com slash join and signing up for the waitlist right now.
By signing up for the waitlist, you'll be the first to know when we start accepting
applications.
With that said, I hope you've enjoyed today's video and I'll see you in the next one.
