mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-05-01 03:08:01 +00:00
feat(errors): Switch Error::custom to use Into<String>
This commit is contained in:
+1
-1
@@ -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;
|
||||
|
||||
@@ -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()) }
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user