Mac*_*cki 3 error-handling std traits rust
Rust文档显示了std::io::Error使用创建的
let custom_error = Error::new(ErrorKind::Other, "oh no!");
Run Code Online (Sandbox Code Playgroud)
并且new有一个类型签名
fn new<E>(kind: ErrorKind, error: E) -> Error
where E: Into<Box<std::error::Error + Send + Sync>>
Run Code Online (Sandbox Code Playgroud)
我找到了一种实现,impl<T: std::error::Error> std::error::Error for Box<T>但找不到&'static str像示例中使用的那样的实现。
使用什么特征来实现Into<Error>字符串?
| 归档时间: |
|
| 查看次数: |
559 次 |
| 最近记录: |