Closed
Description
- I have checked the latest
main
branch to see if this has already been fixed - I have searched existing issues and pull requests for duplicates
URL to the section(s) of the book with this problem:
https://doc.rust-lang.org/book/ch06-01-defining-an-enum.html#the-option-enum-and-its-advantages-over-null-values
Description of the problem:
In my opinion, as a C developer it was hard to come up and think about examples for a value that can be present or absent.
Suggested fix:
With my friend I came up with 3 different examples I think can really give a good example for the Option enum.
The 3 are:
The C library function strstr which searches for a string inside another string - it can either find one or not (and it's not an error).
A recv from a socket which is none blocking, it may get data back or it may not.
Read an environment variable - it may have been defined or it may have not
I think the best one is the third one but I'm open to hear your opinions.
Metadata
Metadata
Assignees
Labels
No labels