From d8477e9f1f8d687f7e8cecd3abf634304a6b351f Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Fri, 8 Feb 2019 18:11:52 -0800 Subject: Simplify error handling in the parse function This patch changes the error handling in the args' module parse function to use the Result's map_err instead of a more verbose if let expression. --- nitrocli/src/args.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/nitrocli/src/args.rs b/nitrocli/src/args.rs index 43f866d..3331779 100644 --- a/nitrocli/src/args.rs +++ b/nitrocli/src/args.rs @@ -177,11 +177,9 @@ fn parse( args: Vec, ) -> Result<()> { let (stdout, stderr) = ctx.stdio(); - if let Err(err) = parser.parse(args, stdout, stderr) { - Err(Error::ArgparseError(err)) - } else { - Ok(()) - } + parser + .parse(args, stdout, stderr) + .map_err(Error::ArgparseError) } /// Inquire the status of the nitrokey. -- cgit v1.2.1