Rust 为结果返回'map\u err',失败
我正在找出返回Rust 为结果返回'map\u err',失败,rust,Rust,我正在找出返回map\u err时以下操作失败的原因: Compiling playground v0.0.1 (/playground) error[E0308]: mismatched types --> src/main.rs:37:5 | 36 | fn R() -> Result<i32, MyError> { | -------------------- expected `std::result::Result<i3
map\u err
时以下操作失败的原因:
Compiling playground v0.0.1 (/playground)
error[E0308]: mismatched types
--> src/main.rs:37:5
|
36 | fn R() -> Result<i32, MyError> {
| -------------------- expected `std::result::Result<i32, MyError>` because of return type
37 | decode().map_err(|e| Err(MyError {v: "changed".to_string() }))
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `MyError`, found enum `std::result::Result`
|
= note: expected enum `std::result::Result<_, MyError>`
found enum `std::result::Result<_, std::result::Result<_, MyError>>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`.
如果您查看,您将看到它期望一个采用错误类型并返回错误类型的闭包,而不是结果
decode().map_err(|e| MyError {v: "changed".to_string() })