Ownership basics
Write a function that takes a String, returns its length, and explain why the original variable is moved.
Languages / Knowledge library
a memory-safe systems programming language
Rust helps you build fast, low-level software with strong memory safety guarantees and no garbage collector. It reduces common bugs (null misuse, use-after-free, data races) while keeping C/C++-class performance.
Started by Graydon Hoare in 2006; first announced publicly by Mozilla in 2010. Rust 1.0 (stable) released in 2015. Cargo became a major productivity advantage for builds and dependency management. Rust Foundation launched in 2021 to support governance, trademarks, and ecosystem stewardship. Rust editions (2015, 2018, 2021, 2024) allow language evolution with smoother migration.
Work through these exercises in order. Try the task before opening a reference.
Write a function that takes a String, returns its length, and explain why the original variable is moved.
Implement a function that returns the first word of a &str as a slice (&str) without allocating.
Build a thread-safe counter with Arc<Mutex<i32>> across 4 threads and print the final value.
Read a text file into String using Result and ?; propagate errors instead of panicking.
Create a tiny CLI that accepts a filename and word, then counts matching lines safely.
A manufacturer of industrial environmental sensors that must process high-frequency telemetry data on resource-constrained hardware.
The existing C-based firmware frequently suffers from buffer overflows and dangling pointer errors, leading to intermittent system crashes that are difficult to debug in remote field deployments.
By migrating the data processing layer to Rust, the team leverages the ownership model and strict type system to enforce memory safety at compile-time, effectively eliminating entire classes of memory-related vulnerabilities before the code is ever deployed to the hardware.
This diagram illustrates how Rust ensures memory safety during the development of embedded sensor firmware.
Raw telemetry data stream
Ownership-managed processing
Static safety verification
Memory-safe firmware
This code demonstrates defining a data structure and processing it using Rust's ownership model, which prevents memory errors by ensuring data is handled predictably.
struct SensorData { value: f64 } // Define memory-safe structure
fn process(data: SensorData) { // Ownership is transferred
let val = data.value; // Safe access without dangling pointers
}The firmware achieves a higher level of stability and reliability, significantly reducing the frequency of field-deployed device failures caused by memory mismanagement.
The primary tradeoff is a steeper learning curve for developers transitioning from C, as they must adapt to the borrow checker's strict rules; this can be verified by monitoring the frequency of compiler-rejected code during the initial development phase.