Skip to content
This repository was archived by the owner on Aug 16, 2021. It is now read-only.

Commit 94f263a

Browse files
committed
More general ErrorKind::Msg creation.
1 parent 3e8a7a6 commit 94f263a

File tree

1 file changed

+6
-19
lines changed

1 file changed

+6
-19
lines changed

src/lib.rs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -426,16 +426,9 @@ macro_rules! error_chain {
426426
}
427427
}
428428

429-
impl<'a> From<&'a str> for $error_name {
430-
fn from(s: &'a str) -> Self {
431-
$error_name(s.into(),
432-
(None, $crate::make_backtrace()))
433-
}
434-
}
435-
436-
impl From<String> for $error_name {
437-
fn from(s: String) -> Self {
438-
$error_name(s.into(),
429+
impl<S: Into<String>> From<S> for $error_name {
430+
fn from(s: S) -> Self {
431+
$error_name(s.into().into(),
439432
(None, $crate::make_backtrace()))
440433
}
441434
}
@@ -490,15 +483,9 @@ macro_rules! error_chain {
490483
}
491484
) *
492485

493-
impl<'a> From<&'a str> for $error_kind_name {
494-
fn from(s: &'a str) -> Self {
495-
$error_kind_name::Msg(s.to_string())
496-
}
497-
}
498-
499-
impl From<String> for $error_kind_name {
500-
fn from(s: String) -> Self {
501-
$error_kind_name::Msg(s)
486+
impl<S: Into<String>> From<S> for $error_kind_name {
487+
fn from(s: S) -> Self {
488+
$error_kind_name::Msg(s.into())
502489
}
503490
}
504491

0 commit comments

Comments
 (0)