From e0c040a3a25b2c3028a6eb7e440df73c86cccc0c Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 15 Apr 2017 12:36:43 -0700 Subject: [PATCH] Document MapAccess misuse --- serde/src/de/mod.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/serde/src/de/mod.rs b/serde/src/de/mod.rs index 79ecd9b0..245aa6ea 100644 --- a/serde/src/de/mod.rs +++ b/serde/src/de/mod.rs @@ -1498,6 +1498,11 @@ pub trait MapAccess<'de> { /// /// `Deserialize` implementations should typically use /// `MapAccess::next_value` instead. + /// + /// # Panics + /// + /// Calling `next_value_seed` before `next_key_seed` is incorrect and is + /// allowed to panic or return bogus results. fn next_value_seed(&mut self, seed: V) -> Result where V: DeserializeSeed<'de>; @@ -1546,6 +1551,11 @@ pub trait MapAccess<'de> { /// /// This method exists as a convenience for `Deserialize` implementations. /// `MapAccess` implementations should not override the default behavior. + /// + /// # Panics + /// + /// Calling `next_value` before `next_key` is incorrect and is allowed to + /// panic or return bogus results. #[inline] fn next_value(&mut self) -> Result where