-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
as?
operator
#355
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For convenience, I'd like there to be an operator which allows inline "unwrapping" of a value as a particular type. For example, let's say there's an enum called
Type
:An instance of
Type
could be any one of its variants. To make use of the data contained in the variants, we can use thematch
expression:This however, can be a bit cumbersome if you only care about one particular variant. This
as?
operator would operate on a value and a typeT
and return anOption<T>
which will be present if the value is of typeT
, andNone
otherwise. For exampleThe text was updated successfully, but these errors were encountered: