Pybites Logo Rust Platform

Fibonacci Sequence

Medium +3 pts

🎯 Python 3.10 introduced structural pattern matching with match/case. Rust has had match from the start — and it's one of the language's most powerful features.

match in Rust

Where Python uses if/elif chains or match/case, Rust uses match expressions:

match n {
    0 => println!("zero"),
    1 => println!("one"),
    _ => println!("something else"),  // _ is the catch-all (like Python's case _)
}

Two things make Rust's match stand out:

  1. It's exhaustive — you must handle every possible case. Forget a variant? Compiler error. This prevents bugs that if/

Login to see the full exercise.