mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-05-01 11:18:01 +00:00
Move RenameRule parse error message to a Display impl
This commit is contained in:
@@ -5,6 +5,8 @@
|
||||
#[allow(deprecated, unused_imports)]
|
||||
use std::ascii::AsciiExt;
|
||||
|
||||
use std::fmt::{self, Display};
|
||||
|
||||
use self::RenameRule::*;
|
||||
|
||||
/// The different possible ways to change case of fields in a struct, or variants in an enum.
|
||||
@@ -108,6 +110,16 @@ pub struct ParseError<'a> {
|
||||
unknown: &'a str,
|
||||
}
|
||||
|
||||
impl<'a> Display for ParseError<'a> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(
|
||||
f,
|
||||
"unknown rename rule for #[serde(rename_all = {:?})]",
|
||||
self.unknown,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rename_variants() {
|
||||
for &(original, lower, upper, camel, snake, screaming, kebab, screaming_kebab) in &[
|
||||
|
||||
Reference in New Issue
Block a user