Rust 错误[E0277]:特性绑定'std::result::result<;\,盒子<;archivebzip2错误>>;:std::error::error`不满足
当我使用此Rust 错误[E0277]:特性绑定'std::result::result<;\,盒子<;archivebzip2错误>>;:std::error::error`不满足,rust,Rust,当我使用此映射时语句: error[E0277]: the trait bound `std::result::Result<_, Box<ArchiveBzip2Error>>: std::error::Error` is not satisfied --> src/archive/bzip2file.rs:58:101 | 58 | ... .file_name().ok_or(Err(Box::new(Archiv
映射时
语句:
error[E0277]: the trait bound `std::result::Result<_, Box<ArchiveBzip2Error>>: std::error::Error` is not satisfied
--> src/archive/bzip2file.rs:58:101
|
58 | ... .file_name().ok_or(Err(Box::new(ArchiveBzip2Error::InvalidArchive)))?
| ^ the trait `std::error::Error` is not implemented for `std::result::Result<_, Box<ArchiveBzip2Error>>`
|
= note: required because of the requirements on the impl of `From<std::result::Result<_, Box<ArchiveBzip2Error>>>` for `Box<dyn std::error::Error>`
= note: required by `from`
.map(| mut entry |->结果{
Ok(框::new(entry.path())或| else(| e | Err(e))?
.file_name().ok_或(Err(Box::new(ArchiveBzip2Error::InvalidArchive))?
.to_str()?
))
})
我收到这个错误:
error[E0277]: the trait bound `std::result::Result<_, Box<ArchiveBzip2Error>>: std::error::Error` is not satisfied
--> src/archive/bzip2file.rs:58:101
|
58 | ... .file_name().ok_or(Err(Box::new(ArchiveBzip2Error::InvalidArchive)))?
| ^ the trait `std::error::Error` is not implemented for `std::result::Result<_, Box<ArchiveBzip2Error>>`
|
= note: required because of the requirements on the impl of `From<std::result::Result<_, Box<ArchiveBzip2Error>>>` for `Box<dyn std::error::Error>`
= note: required by `from`
这是IDE的完整上下文,带有类型提示:
的签名是
考虑
.file_name().ok_or(Box::new(ArchiveBzip2Error::InvalidArchive))?
哎呀,这显然是个错误。谢谢
.file_name().ok_or(Box::new(ArchiveBzip2Error::InvalidArchive))?