We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 6559e0d + 1fd1fe6 commit 111cfaeCopy full SHA for 111cfae
src/error/multiple_error_types/boxing_errors.md
@@ -28,10 +28,10 @@ impl error::Error for EmptyVec {}
28
29
fn double_first(vec: Vec<&str>) -> Result<i32> {
30
vec.first()
31
- .ok_or_else(|| EmptyVec.into()) // Converts to Box
+ .ok_or_else(|| EmptyVec.into()) // Converts to Box using Into trait.
32
.and_then(|s| {
33
s.parse::<i32>()
34
- .map_err(|e| e.into()) // Converts to Box
+ .map_err(From::from) // Converts to Box using From::from fn pointer.
35
.map(|i| 2 * i)
36
})
37
}
0 commit comments