From 8bbf12491b53ba85baf061e246349b570c704b65 Mon Sep 17 00:00:00 2001 From: kaiserd Date: Fri, 18 Oct 2019 11:17:04 +0200 Subject: [PATCH] refactor: simplify extracting Result from Option Using the ?, the code basically extracted an Option from the Result we just built. Just to again wrap it in a Result. We can just return the Result. --- src/error/multiple_error_types/option_result.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/error/multiple_error_types/option_result.md b/src/error/multiple_error_types/option_result.md index 793673f8df..d2273f698f 100644 --- a/src/error/multiple_error_types/option_result.md +++ b/src/error/multiple_error_types/option_result.md @@ -39,9 +39,7 @@ fn double_first(vec: Vec<&str>) -> Result, ParseIntError> { first.parse::().map(|n| 2 * n) }); - let opt = opt.map_or(Ok(None), |r| r.map(Some))?; - - Ok(opt) + opt.map_or(Ok(None), |r| r.map(Some)) } fn main() {