提交 d0c32834 编写于 作者: M Manish Goregaokar

Rollup merge of #23979 - Ryman:error_from_string, r=alexcrichton

......@@ -88,8 +88,8 @@ fn from(err: E) -> Box<Error + Send + 'a> {
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b> From<&'b str> for Box<Error + Send + 'a> {
fn from(err: &'b str) -> Box<Error + Send + 'a> {
impl From<String> for Box<Error + Send> {
fn from(err: String) -> Box<Error + Send> {
#[derive(Debug)]
struct StringError(String);
......@@ -103,7 +103,14 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
}
}
Box::new(StringError(String::from_str(err)))
Box::new(StringError(err))
}
}
#[stable(feature = "rust1", since = "1.0.0")]
impl<'a, 'b> From<&'b str> for Box<Error + Send + 'a> {
fn from(err: &'b str) -> Box<Error + Send + 'a> {
From::from(String::from_str(err))
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册