diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 56c422f24..a251e7159 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -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>(msg: T) -> Self; /// Raised when a `Deserialize` type unexpectedly hit the end of the stream. fn end_of_stream() -> Self; diff --git a/serde/src/de/value.rs b/serde/src/de/value.rs index 773c19df3..791cb900f 100644 --- a/serde/src/de/value.rs +++ b/serde/src/de/value.rs @@ -50,7 +50,7 @@ pub enum Error { } impl de::Error for Error { - fn custom(msg: String) -> Self { Error::Custom(msg) } + fn custom>(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()) } diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index 01368afb6..7129ebfb0 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -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>(msg: T) -> Self; /// Raised when a `Serialize` was passed an incorrect value. fn invalid_value(msg: &str) -> Self { diff --git a/serde_tests/benches/bench_enum.rs b/serde_tests/benches/bench_enum.rs index 220f0de36..e5deaad77 100644 --- a/serde_tests/benches/bench_enum.rs +++ b/serde_tests/benches/bench_enum.rs @@ -22,7 +22,7 @@ pub enum Error { } impl serde::de::Error for Error { - fn custom(_: String) -> Error { Error::Syntax } + fn custom>(_: T) -> Error { Error::Syntax } fn end_of_stream() -> Error { Error::EndOfStream } diff --git a/serde_tests/benches/bench_map.rs b/serde_tests/benches/bench_map.rs index beab38f8d..32bc44150 100644 --- a/serde_tests/benches/bench_map.rs +++ b/serde_tests/benches/bench_map.rs @@ -19,7 +19,7 @@ pub enum Error { } impl serde::de::Error for Error { - fn custom(_: String) -> Error { Error::Syntax } + fn custom>(_: T) -> Error { Error::Syntax } fn end_of_stream() -> Error { Error::EndOfStream } diff --git a/serde_tests/benches/bench_struct.rs b/serde_tests/benches/bench_struct.rs index 7ad311f7d..402230d40 100644 --- a/serde_tests/benches/bench_struct.rs +++ b/serde_tests/benches/bench_struct.rs @@ -35,7 +35,7 @@ pub enum Error { } impl serde::de::Error for Error { - fn custom(_: String) -> Error { Error::Syntax } + fn custom>(_: T) -> Error { Error::Syntax } fn end_of_stream() -> Error { Error::EndOfStream } diff --git a/serde_tests/benches/bench_vec.rs b/serde_tests/benches/bench_vec.rs index 01edcf09e..96a4e6379 100644 --- a/serde_tests/benches/bench_vec.rs +++ b/serde_tests/benches/bench_vec.rs @@ -17,7 +17,7 @@ pub enum Error { } impl serde::de::Error for Error { - fn custom(_: String) -> Error { Error::Syntax } + fn custom>(_: T) -> Error { Error::Syntax } fn end_of_stream() -> Error { Error::EndOfStream } diff --git a/serde_tests/tests/test_bytes.rs b/serde_tests/tests/test_bytes.rs index 93fe97057..52e159f83 100644 --- a/serde_tests/tests/test_bytes.rs +++ b/serde_tests/tests/test_bytes.rs @@ -10,11 +10,11 @@ use serde::bytes::{ByteBuf, Bytes}; struct Error; impl serde::ser::Error for Error { - fn custom(_: String) -> Error { Error } + fn custom>(_: T) -> Error { Error } } impl serde::de::Error for Error { - fn custom(_: String) -> Error { Error } + fn custom>(_: T) -> Error { Error } fn end_of_stream() -> Error { Error } } diff --git a/serde_tests/tests/token.rs b/serde_tests/tests/token.rs index 16be21b14..7a537a6ac 100644 --- a/serde_tests/tests/token.rs +++ b/serde_tests/tests/token.rs @@ -416,7 +416,7 @@ pub enum Error { } impl ser::Error for Error { - fn custom(_: String) -> Error { Error::SyntaxError } + fn custom>(_: T) -> Error { Error::SyntaxError } fn invalid_value(msg: &str) -> Error { Error::InvalidValue(msg.to_owned()) @@ -424,7 +424,7 @@ impl ser::Error for Error { } impl de::Error for Error { - fn custom(_: String) -> Error { Error::SyntaxError } + fn custom>(_: T) -> Error { Error::SyntaxError } fn end_of_stream() -> Error { Error::EndOfStreamError }