Skip to content
Quiz · Enums and match · lesson 5 of 8

Quiz — match and all variants

Question 1 of 2

What does the program print?

Rust
enum Shape {
    Rect(u32, u32),
    Square(u32),
}

fn main() {
    let shapes = [Shape::Rect(3, 4), Shape::Square(5)];
    match shapes[0] {
        Shape::Square(a) => println!("{}", a * a),
        Shape::Rect(w, h) => println!("{}", w * h),
    }
}