Skip to content

refactor `match` statements

Michael Aaron Murphy requested to merge nivkner:flat_match into master

Created by: nivkner

The original problem I had was that when trying to compile a6e0e86 was that I got errors such as:

error: expected one of `,`, `.`, `?`, or `}`, found `Err`
  --> src/shell/assignments.rs:70:33
   |
69 |                                 }
   |                                  - expected one of `,`, `.`, `?`, or `}` here
70 |                                 Err(why) => {
   |                                 ^^^ unexpected token

The cause of it might have been the inner match's {} being confused for a multi-line match arm.

I have no idea how that slipped by, since its a syntax error. I deleted and cloned the repository again just in case; still got the same error.

Instead of simply adding , at the end, I decided refactor the methods to avoid such problems altogether.

This PR addresses readability issues, such as unnecessary nested matchs, variable names being used multiple times for different items, or functions being used outside of the match statement as though independent of the outcome, despite only happening in the first arm's case.

Merge request reports