Enums allow you to define a custom type by enumerating all its values. Option is a useful enum to explore.
- Let's look at enumerations, also referred to as enums.…Enums allow you to define a type by enumerating…its possible values.…First, we'll define and use an enum to show how…an enum can encode meaning along with data.…Next, we'll explore a particularly useful enum…called Option, which expresses that a value can…be either something or nothing.…So let's look at a situation where we might want…to express in code and see why enums are useful…and more appropriate than structs.…
Let's create a new project...…Cargo new enums followed by bin.…And let's cd into the project.…Now that we have created our project, let's go…to Visual Studio Code.…Let's look at a situation where we might want…to express in code and see why enums are useful…and more appropriate than structs in a particular case.…Say we need to work with IP addresses.…Currently, two major standards are used for IP addresses:…Version four and version six.…
Let's expand a project here and in the meantime rs,…let's declare our enum.…So the name of the enum would be IP Address Kind…
- Installing Rust
- Data types
- Adjusting memory allocation
- Setting up race conditions
- Working with functions
- Exploring references and borrowing
- Using structs
- Method syntax
- Demonstrating recoverable errors with Result
- Working with enums
- Getting user input
Skill Level Beginner
Programming Foundations: Data Structures (2014)with Simon Allardice2h 29m Intermediate
1. Hello, Rust!
2. Basic Programming Concepts
3. Ownership in Rust
4. Data Handling and Pattern Matching in Rust
5. Error Handling
6. Sample Rust Project: The Guessing Game
Next steps1m 14s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.