diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 75c3f4b0..637bab6d 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -403,6 +403,16 @@ pub trait Deserializer { self.visit_seq(visitor) } + /// This method hints that the `Deserialize` type is expecting some sort of struct key mapping. + /// This allows deserializers to choose between &str, usize, or &[u8] to properly deserialize a + /// struct key. + #[inline] + fn visit_struct_key(&mut self, visitor: V) -> Result + where V: Visitor, + { + self.visit(visitor) + } + /// Specify a format string for the deserializer. /// /// The deserializer format is used to determine which format diff --git a/serde_codegen/src/de.rs b/serde_codegen/src/de.rs index 6980507b..a327993c 100644 --- a/serde_codegen/src/de.rs +++ b/serde_codegen/src/de.rs @@ -917,7 +917,7 @@ fn deserialize_field_visitor( } } - deserializer.visit(__FieldVisitor::{ phantom: PhantomData }) + deserializer.visit_struct_key(__FieldVisitor::{ phantom: PhantomData }) } } ).unwrap();