-> rustc --explain E0382

The Borrow Checker is the hardest part of the Rust learning curve. It forces you to think about Ownership and Lifetimes at compile time.

The Golden Rules

  1. Each value in Rust has a variable that’s called its owner.
  2. There can only be one owner at a time.
  3. When the owner goes out of scope, the value will be dropped.

Scenario: The "Use After Move" Error

This was my first major hurdle when building the CPU struct.

❌ The Fail

I tried to pass cpu to a function, then use it again.

use highlighter::highlight;
let code = "...";
highlight(code);
fn main() {
    println!("Hello, World!");
}