From the course: Rust Programming: From Fundamentals to Advanced Concepts with AI-Assisted Development

Unlock this course with a free trial

Join today to access over 25,600 courses taught by industry experts.

Demo: Defining an enum

Demo: Defining an enum

- [Presenter] Now, let's see enums, and we've already seen enums before, but we'll now look into them as in, well, in very technical details here. What we're going to try to do, and an enum stands for an enumerator, and it is another way of grouping something in a category that holds different types of, or different variants, rather, of what we want to do. So in this case, a disc would be, can be, like an SSD solid state drive or a spin drive, which is an HTD. And in some situations, and we'll see this a little bit later, these can also hold a little bit data. These can have like an unsigned 32 bit size of an integer, and we can definitely do that. Now, as always, you can add the, the derived debug property onto the enums, just like you would do for structs as well. In this case, I didn't add one to the disk type, because I'm definitely trying to print out the disk size. So, okay, so how do you use them? What, what are, what are some of the things that we can do? Well, let's take a…

Contents