Rust Programming Tutorial #37 - Option (Enum)

preview_player
Показать описание
The 'Option' Enum represents either a value (Some) or no value at all (None). It is common to see this in Rust with many methods and functions returning this particular type.

It's useful because it forces us to deal with unexpected situations such as when the expected return value of a function does not actually provide a value - because it doesn't exist or can't be found.

In this video we look at a common example of the Option Enum in use and we also define our own function that returns an Option type to truly understand how it works.

For your reference:

If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
Рекомендации по теме
Комментарии
Автор

your my new favourite new favourite free coding teacher

PseudoDope
Автор

Awesome explanation. Also I liked it instantly when you used your own examples which are easy to understand.

TON-vzpe
Автор

Great tutorial. Also, that feature seems quite useful. I wonder why more languages don’t have something similar.

kyleeames
Автор

Hey just stumbled across your channel. In many ways it reminds me of that channel TheNewBoston in style and the way its structured. It's good to see someone giving love and attention to Rust, and cleanly explaining it as you do (sometimes the book they have and documentation can be a bit confusing). Keep up the good work!

tornado
Автор

hello there and thank you for your tutorials on rust programming language.

princessakokosowa
Автор

You should also consider using if let instead of match, it's cleaner that way!

tn
Автор

Great tutorial. I finally understand it

inx
Автор

For some reason when I ran this I got no output and a warning saying that name (where it was defined) was unused. This wouldn't compile and run the way I intended it to until I changed 'name' into 'my_name'. Is 'name' a reserved word in rust?

CamdenBloke
Автор

damn bro. thanks. wash confused as hell reading the documentation.

kid_kulafu_
Автор

Yep, that works. Thanks for posting this up :)

WayneRiesterer