From 1fd1fe6dbd33b55546904d7caf9b31017288343d Mon Sep 17 00:00:00 2001 From: dcechano Date: Fri, 10 Jan 2025 00:24:42 -0500 Subject: [PATCH] convert to box using From --- src/error/multiple_error_types/boxing_errors.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/error/multiple_error_types/boxing_errors.md b/src/error/multiple_error_types/boxing_errors.md index ca506d4131..b2b4753f31 100644 --- a/src/error/multiple_error_types/boxing_errors.md +++ b/src/error/multiple_error_types/boxing_errors.md @@ -28,10 +28,10 @@ impl error::Error for EmptyVec {} fn double_first(vec: Vec<&str>) -> Result { vec.first() - .ok_or_else(|| EmptyVec.into()) // Converts to Box + .ok_or_else(|| EmptyVec.into()) // Converts to Box using Into trait. .and_then(|s| { s.parse::() - .map_err(|e| e.into()) // Converts to Box + .map_err(From::from) // Converts to Box using From::from fn pointer. .map(|i| 2 * i) }) }