Skip to main content
InterviewHubPRO
Section Overview
Q8

Question 8 of 50

Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

16%
Rust Systems & Tokio (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)

What are Rust Enums and Algebraic Data Types (Pattern Matching)?

junior LevelCode ExampleTypeScript

In Simple Words: Rust enums can hold associated data in each variant (Tagged Unions / Sum Types):

rust
enum WebEvent {
    PageLoad,
    KeyPress(char),
    Paste(String),
    Click { x: i64, y: i64 },
}
  • Handled exhaustively using match: the compiler guarantees every possible enum variant is handled, preventing unhandled edge case bugs.