mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-09 20:11:01 +00:00
Add free-form option for Unexpected
This commit is contained in:
@@ -269,6 +269,13 @@ pub enum Unexpected<'a> {
|
|||||||
|
|
||||||
/// The input contained a struct variant that was not expected.
|
/// The input contained a struct variant that was not expected.
|
||||||
StructVariant,
|
StructVariant,
|
||||||
|
|
||||||
|
/// A message stating what uncategorized thing the input contained that was
|
||||||
|
/// not expected.
|
||||||
|
///
|
||||||
|
/// The message should be a noun or noun phrase, not capitalized and without
|
||||||
|
/// a period. An example message is "unoriginal superhero".
|
||||||
|
Other(&'a str),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> fmt::Display for Unexpected<'a> {
|
impl<'a> fmt::Display for Unexpected<'a> {
|
||||||
@@ -292,6 +299,7 @@ impl<'a> fmt::Display for Unexpected<'a> {
|
|||||||
NewtypeVariant => write!(formatter, "newtype variant"),
|
NewtypeVariant => write!(formatter, "newtype variant"),
|
||||||
TupleVariant => write!(formatter, "tuple variant"),
|
TupleVariant => write!(formatter, "tuple variant"),
|
||||||
StructVariant => write!(formatter, "struct variant"),
|
StructVariant => write!(formatter, "struct variant"),
|
||||||
|
Other(other) => formatter.write_str(other),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user