Join Abhiram Ravikumar for an in-depth discussion in this video Enums with multiple types, part of First Look: Rust.
- [Instructor] Let's look at another example of an Enum.…This one has a wide variety of types…embedded in its variants.…This Enum has four variants, with different types.…Quit has no data associated with it at all.…Move includes an anonymous struct inside it.…Write includes a single string.…ChangeColor includes three i32 values.…Let's now write this Enum here.…Enum followed by the name of the Enum,…which is Message here.…And then the four types, Quit, Move,…This takes two i32 types.…
(keyboard typing)…Write, this takes a String.…(keyboard typing)…and ChangeColor, this takes three i32 types.…There's one more similarity between Enums and structs.…Just as we're able to define methods on structs…using the impl block,…it also able to define methods on Enums.…
Let's go ahead and implement a method.…impl, followed by the name of the enum…and then, all the functions that go for this enum.…Let's say fn, call,…and then &self.…As we discussed in the previous video,…note that all the methods start with a self parameter here.…Let's say println…
- 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.