字符串 io::Errors 是如何创建的
How are string io::Errors created
Rust docs 显示 std::io::Error
使用
创建
let custom_error = Error::new(ErrorKind::Other, "oh no!");
和new
有一个type signature的
fn new<E>(kind: ErrorKind, error: E) -> Error
where E: Into<Box<std::error::Error + Send + Sync>>
我找到了 impl<T: std::error::Error> std::error::Error for Box<T>
的 implementation,但找不到 &'static str
的 &'static str
,就像示例中使用的那样。
什么特征用于实现字符串的Into<Error>
?
Rust docs 显示 std::io::Error
使用
let custom_error = Error::new(ErrorKind::Other, "oh no!");
和new
有一个type signature的
fn new<E>(kind: ErrorKind, error: E) -> Error
where E: Into<Box<std::error::Error + Send + Sync>>
我找到了 impl<T: std::error::Error> std::error::Error for Box<T>
的 implementation,但找不到 &'static str
的 &'static str
,就像示例中使用的那样。
什么特征用于实现字符串的Into<Error>
?