Avatar ·

How to access enum values in Rust? Understanding match, if let and other methods

Hello everyone! I recently started learning Rust and encountered a problem when working with enums. I created a simple enum to represent order status: ```rust enum OrderStatus { Pending, Processing, Shipped(String), Delivered { date: String, signature: bool }, } ``` But I don't understand how to extract data from the variants. For example, when the status is `Shipped`, I need to get the tracking number (`String`). When `Delivered` — the date and signature. Simply writing `order_status.tracking_number` doesn't work — the compiler complains. I tried using `match`, but I keep getting confused with the syntax and getting errors like "expected enum, found &str". The documentation mentions `if let` and `unwrap`, but I don't understand when to use which. Please advise on the correct approach.