You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This could be expressed by putting the cursor on the _ and invoking an assist that duplicates the arm with more specific patterns. (Or, “Fill match arms” could always descend into nested enums and rely on the user to delete unwanted ones, but that could potentially lead to quite an expansion in some cases, so I don’t think it is wise.) In general, I think it would make sense to have an assist that replaces an _ pattern or identifier pattern with an enum variant (or struct) pattern, and then duplicates the arm for all variants produced this way.
A different but closely related case is that I might be in the position of currently having some of these arms but not all (hence getting a non-exhaustive match error), and wanting to fill in the missing arms:
match e {Some(Example::One) => todo!(),None => todo!(),}
In this case, the error's span is e (the same place that “Fill match arms” is available), but RA doesn't offer any assist/fix that will fill in the missing arm. In this case, I think “Fill match arms” should be available and fill in the missing Some(Example::Two) arm. This part won’t require any new UI design.
The text was updated successfully, but these errors were encountered:
Consider the following code:
Invoking “Fill match arms” on
e
will currently produceHowever, I might want to match the inner enum, to produce:
This could be expressed by putting the cursor on the
_
and invoking an assist that duplicates the arm with more specific patterns. (Or, “Fill match arms” could always descend into nested enums and rely on the user to delete unwanted ones, but that could potentially lead to quite an expansion in some cases, so I don’t think it is wise.) In general, I think it would make sense to have an assist that replaces an_
pattern or identifier pattern with an enum variant (or struct) pattern, and then duplicates the arm for all variants produced this way.A different but closely related case is that I might be in the position of currently having some of these arms but not all (hence getting a non-exhaustive match error), and wanting to fill in the missing arms:
In this case, the error's span is
e
(the same place that “Fill match arms” is available), but RA doesn't offer any assist/fix that will fill in the missing arm. In this case, I think “Fill match arms” should be available and fill in the missingSome(Example::Two)
arm. This part won’t require any new UI design.The text was updated successfully, but these errors were encountered: