Skip to content

Commit 111cfae

Browse files
authored
Merge pull request #1906 from dcechano/Box-errors-change
Use `From::from` fn pointer to convert to boxed errors
2 parents 6559e0d + 1fd1fe6 commit 111cfae

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/error/multiple_error_types/boxing_errors.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ impl error::Error for EmptyVec {}
2828
2929
fn double_first(vec: Vec<&str>) -> Result<i32> {
3030
vec.first()
31-
.ok_or_else(|| EmptyVec.into()) // Converts to Box
31+
.ok_or_else(|| EmptyVec.into()) // Converts to Box using Into trait.
3232
.and_then(|s| {
3333
s.parse::<i32>()
34-
.map_err(|e| e.into()) // Converts to Box
34+
.map_err(From::from) // Converts to Box using From::from fn pointer.
3535
.map(|i| 2 * i)
3636
})
3737
}

0 commit comments

Comments
 (0)