Examples of Enum in Rust
There are different examples of enum decleration and usage in Rust programming language.
Below files are associated with Rust turorial episode No 13 in Persian:
C Like enums
Example of C like enums and getting associated number to each variant by compiler are in the
CLike Enums.rs file.
C Like enums with custom values
Example of how we can change stored value of enum varients in the memory is in the
Http Status.rs file. Explained by a simple enum representing brief version of http statuts.
Enum with Values
Example of how storing values in the enums is in the
Enum with Values.rs file.
Enum with struct-like variants
The example of how we could declare enum varients like structs is in the
Struct Variants.rs file.
Using enums in the structs
We can use enums like fields of a struct. The example of this usage is in the
Using Enums in Structs.rs file.