Semicolon to end a match line with no return

This minor annoyance has come up for me several times recently, and I feel this is a reasonable solution,

match something{
   Case(n) => {
    OtherCase => could_just_end_with_a_semicolon();

So normally a match case ends with a comma but if the function returns something you don't want to handle, (eg tree insert returns an option of the previous value) You have to create a block to allow for the semicolon to cancel the result.

But if there was a semantic difference between a comma and a semicolon, then, the block would not be needed for a single line, action.


1 Like

Not returning from a match branch is pretty trivial:

match something {
   Case(n) => { returns_something_i_dont_want(n); },

I don't see the benefit of this.


And of course

match something {
   Case(n) => drop(returns_something_i_dont_want(n)),

Perhaps my problem is with rustfmt, but rustfmt insists that this should be spread over three lines.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.