Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/aienux/blob/main/vendor/serde_json/tests/regression/issue979.rs # aienux Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `aienux / vendor / serde_json / tests / regression / issue979.rs` 29 lines ยท 758 bytes Raw Blame History 1 use serde::de::{Deserializer, EnumAccess, VariantAccess, Visitor}; 2 use std::fmt; 3 4 struct EnumVisitor; 5 6 impl<'de> Visitor<'de> for EnumVisitor { 7 type Value = (Vec, ()); 8 9 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { 10 formatter.write_str("enum") 11 } 12 13 fn visit_enum(self, data: A) -> Result 14 where 15 A: EnumAccess<'de>, 16 { 17 let (key, variant) = data.variant()?; 18 variant.newtype_variant::<()>()?; 19 Ok((key, ())) 20 } 21 } 22 23 #[test] 24 fn test() { 25 let mut de = serde_json::Deserializer::from_str("{[true]: null}"); 26 let err = de.deserialize_enum("name", &[], EnumVisitor).unwrap_err(); 27 28 assert!(err.to_string().contains("key must be a string")); 29 }