If result of match not captured, why must arms have same type?

match some_expr {
  A => arm_A
  B => arm_B

right now, it is required that arm_A and arm_B have the same type, or wrapped with a { ... ;} to force to ().

However, if the value of the match is not captured, and the arms are executed for their side effect, why is this required ?

We have situations where HashMap::insert() has return type Option<V>, and now we have to wrap in { ... ; }

1 Like

Every expression must have a single unambiguous type.


If you don't like the brace you can just drop(arm_A) it.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.