pub fn serde_introspect<'de, T>() -> &'static [&'static str]where
T: Deserialize<'de>,
Expand description
Gets the serialization names for structs and enums.
ยงExample
use serde_aux::prelude::*;
#[derive(serde::Deserialize, Debug)]
struct AnotherStruct {
#[serde(rename = "a3")]
aaa: Option<i64>,
#[serde(rename = "b3")]
bbb: i128,
#[serde(rename = "c3")]
ccc: u128,
}
let fields = serde_introspect::<AnotherStruct>();
assert_eq!(fields[0], "a3");
assert_eq!(fields[1], "b3");
assert_eq!(fields[2], "c3");
#[derive(serde::Deserialize, Debug)]
enum SomeEnum {
#[serde(rename = "a")]
EnumA,
#[serde(rename = "b")]
EnumB
}
let variants = serde_introspect::<SomeEnum>();
assert_eq!(variants[0], "a");
assert_eq!(variants[1], "b");