interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / serde_json / tests / regression / issue979.rs

29 lines · 758 bytes Raw Blame History
1use serde::de::{Deserializer, EnumAccess, VariantAccess, Visitor};
2use std::fmt;
3
4struct EnumVisitor;
5
6impl<'de> Visitor<'de> for EnumVisitor {
7 type Value = (Vec<bool>, ());
8
9 fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
10 formatter.write_str("enum")
11 }
12
13 fn visit_enum<A>(self, data: A) -> Result<Self::Value, A::Error>
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]
24fn 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}