feat(errors): Switch Error::custom to use Into<String>

This commit is contained in:
Erick Tryzelaar
2016-02-26 21:12:16 -08:00
parent 6ea632e98b
commit ec75f22396
9 changed files with 11 additions and 11 deletions
+1 -1
View File
@@ -12,7 +12,7 @@ mod from_primitive;
/// `Deserializer` error.
pub trait Error: Sized + error::Error {
/// Raised when there is general error when deserializing a type.
fn custom(msg: String) -> Self;
fn custom<T: Into<String>>(msg: T) -> Self;
/// Raised when a `Deserialize` type unexpectedly hit the end of the stream.
fn end_of_stream() -> Self;
+1 -1
View File
@@ -50,7 +50,7 @@ pub enum Error {
}
impl de::Error for Error {
fn custom(msg: String) -> Self { Error::Custom(msg) }
fn custom<T: Into<String>>(msg: T) -> Self { Error::Custom(msg.into()) }
fn end_of_stream() -> Self { Error::EndOfStream }
fn invalid_type(ty: de::Type) -> Self { Error::InvalidType(ty) }
fn invalid_value(msg: &str) -> Self { Error::InvalidValue(msg.to_owned()) }
+1 -1
View File
@@ -10,7 +10,7 @@ pub mod impls;
/// `Serializer` error.
pub trait Error: Sized + error::Error {
/// Raised when there is general error when deserializing a type.
fn custom(msg: String) -> Self;
fn custom<T: Into<String>>(msg: T) -> Self;
/// Raised when a `Serialize` was passed an incorrect value.
fn invalid_value(msg: &str) -> Self {