Rust program to demonstrate the Match Statement with Enum (Enum Example)
belongs to collection: Rust Enums Programs
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
belongs to collection: Rust Enums Programs
total answers (1)
Program/Source Code:
The source code to demonstrate the Match Statement with Enum is given below. The given program is compiled and executed successfully.
Output:
Explanation:
In the above program, we created an enum Color and functions Fun(), main(). The enum Color contains constants RED, GREEN, and YELLOW.
The Fun() function accepts the enum as a parameter and here we used enum with match statement. In the main() function, we called the Fun() function and printed the appropriate message.
need an explanation for this answer? contact us directly to get an explanation for this answer