Get Me a Job

We’ve seen primitive types, like i32, bool, or str. We’ve seen structs, which let you create more complex types by combining other types. Now it’s time to introduce a third kind of type, enums. These let you create something that may be one of many different things. We’ll start with simple examples, then build up more sophisticated cases.

We’ve played around with a struct called Person for a while now. We’ve given this person fields like name and age. Let’s add a new field, the person’s job. The question is, how do we represent a job? One way would be to use a String:

Get hands-on with 1200+ tech skills courses.