Intro to Embedded Rust Part 4: Ownership and Borrowing | DigiKey @digikey
Intro to Embedded Rust Part 4: Ownership and Borrowing | DigiKey  @digikey
Uploaded February 2026 | Updated September 2026, 2 weeks ago
Rust's ownership and borrowing system can be confusing at first. In this video, we break down the seven fundamental rules that govern how Rust manages memory safely without a garbage collector or runtime overhead. To keep it applicable to embedded systems, we use a stack-based example (rather than relying on the heap examples found in the Rust Book). You'll learn how ownership transfers work, when values are dropped from memory, and how references provide safe access to data without the memory bugs that plague C and C++ programs. No hardware required for this episode: just your computer and the Rust compiler to explore these concepts through hands-on code examples.
The written guide for this episode can be found here: digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-4-ownership-and-borrowing
The GitHub repository containing the Docker image and example code for this series can be found here: github.com/ShawnHymel/introduction-to-embedded-rust
This tutorial provides an in-depth exploration of Rust's memory management rules, covering each principle with clear examples and explanations. We start with basic ownership: how each value has exactly one owner and what happens when ownership is transferred (moved) between variables. You'll understand the difference between types that implement the Copy trait (like primitive integers and arrays) versus types that use move semantics. We explore scoping rules and how Rust automatically deallocates memory when owners go out of scope, eliminating memory leaks without manual cleanup. We then dive into borrowing and references, explaining the crucial rule that you can have either multiple immutable references or one mutable reference at a time.
We also look at why references must always be valid, preventing dangling pointer bugs that cause crashes and security vulnerabilities in other languages. We demonstrate partial moves with compound types like tuples and structs, showing what happens when you move ownership of only part of a value.
We conclude with slice operations, including how to create multiple mutable slices to non-overlapping array regions using split_at_mut() (a useful pattern for working with buffers in embedded systems). Unlike typical Rust tutorials that rely heavily on heap-allocated types (like String and Vec), our examples use stack-only data structures that mirror real embedded development constraints, making this tutorial especially relevant for bare-metal programming.
These ownership and borrowing rules are what make Rust unique among systems programming languages, offering the performance of C with memory safety guarantees typically found only in garbage-collected languages.

Related Link:
digikey.com/en/maker/tutorials/2026/intro-to-embedded-rust-part-4-ownership-and-borrowing

Links:
Getting Started with STM32 and Nucleo: youtube.com/watch?v=hyZS2p1tW-g&list=PLEBQazB0HUyRYuzfi4clXsKUSgorErmBv
Introduction to Real-Time Operating Systems (RTOS): youtube.com/watch?v=F321087yYy4&list=PLEBQazB0HUyQ4hAPU1cJED6t3DU0h34bz
Raspberry Pi Pico 2: digikey.com/en/products/detail/raspberry-pi/SC1631/24627142

Learn more:
Maker.io - digikey.com/en/maker
DigiKey’s Blog – TheCircuit digikey.com/en/blog
Connect with DigiKey on Facebook facebook.com/digikey.electronics
And follow us on X: https://x.com/digikey

Product:
digikey.com/en/products/detail/raspberry-pi/SC1631/24627142
digikey.com/en/products/detail/raspberry-pi/SC1632/26241102
digikey.com/en/products/detail/raspberry-pi/SC1633/25862735
digikey.com/en/products/detail/raspberry-pi/SC1634/26241087
digikey.com/en/products/detail/sparkfun-electronics/13314/6797646
digikey.com/en/products/detail/lite-on-inc/LTL-4224/217584
digikey.com/en/products/detail/stackpole-electronics-inc/CF14JT220R/1830334
digikey.com/en/products/detail/te-connectivity-alcoswitch-switches/1825910-6/1632536
digikey.com/en/products/detail/dfrobot/FIT0096/7597069
digikey.com/en/products/detail/adafruit-industries-llc/1957/6827090
digikey.com/en/products/detail/cvilux-usa/DH-20M50055/13175849

Chapters:
0:00 Intro
0:52 Stack vs. Heap
3:32 Rule 1: Each Value Has an Owner
5:48 Rule 2: Only One Owner at a Time
9:28 Rule 3: Value Dropped When Owner Goes Out of Scope
15:49 Pointers and References
17:56 Rule 4: Only One Mutable Reference or Any Number of Immutable References
26:21 Rule 5: References Must Always Be Valid
29:43 Rule 6: Moving Part of a Value Moves the Whole Value
32:58 Rule 7: Slides Are References to the Whole Value
40:10 Recap
40:41 Reading Assignment
41:36 Conclusion
Intro to Embedded Rust Part 4: Ownership and Borrowing | DigiKeyAdding LIDAR to a Robot - The Byte Sized Engineer | DigiKeySpool Speed Ahead [Maker Update] | Maker.ioIntroduction to FreeCAD Part 3: Shape Binders, Expressions, and Spreadsheets | DigiKeyAsynchronous Buck Converters | Byte Sized #shortMakers Need This Travel Soldering Kit - #BeckySternHow to use an oscilloscope - The Byte Sized Engineer | DigiKeyFavorite Things 2023 -  Becky Stern #shortReading a Smart Meter with a Software Defined Radio - The Byte Sized Engineer | DigiKeyManufacturing the Digital Thread - Factory Tomorrow S4E1 | DigiKeyCrossing the Digital Frontier - Supply Chain Transformed S3 E3 | DigiKeyMapping in 360 Degrees - #thebytesizedengineer | DigiKey
DigiKey |

Intro to Embedded Rust Part 4: Ownership and Borrowing | DigiKey

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER