We’ve covered Enums, Pattern Matching, Methods and Type Parameters under this section. We’ve come across several new keywords of Rust Language.
We’ve understood how we can define enum
and it’s variants
. We also understood how we can use namespace
::
to access variants
.
We also did pattern matching using enum
and writing conditions for all the variants
of the enum
. We understood the use case of _
which is used for catch all condition for variants
of the enum
that are not covered under match
.
We saw how we can define methods
on the enum
using impl
keyword. We understood the use of self
and Self
keyword.
And finally, we saw how Type Parameters like Option
and Result
could help us write code which covers all the positive as well as negative sides of handling values during runtime.
I hope you enjoyed the series of Pattern Matching. Please share your feedback in the comments section.
You can subscribe to my newsletter about The Rust Programming Language here. You can read about all the articles in this series here.