This repository has been archived on 2025-09-14. You can view files and clone it, but cannot push or open issues or pull requests.
Files
zhangyang-zerotierone/zeroidc/vendor/darling/tests/computed_bound.rs
Grant Limberg a59626c971 Bump zeroidc dependencies (#1847)
openidconnect -> 2.5
base64 -> 0.21
url -> 2.3
bytes -> 1.3
2023-01-12 13:24:58 -08:00

43 lines
845 B
Rust

use darling::{FromDeriveInput, FromMeta};
fn parse<T: FromDeriveInput>(src: &str) -> T {
let ast = syn::parse_str(src).unwrap();
FromDeriveInput::from_derive_input(&ast).unwrap()
}
#[derive(FromMeta, PartialEq, Eq, Debug)]
enum Volume {
Whisper,
Talk,
Shout,
}
#[derive(FromDeriveInput)]
#[darling(attributes(speak))]
struct SpeakingOptions<T: Default, U> {
max_volume: U,
#[darling(skip)]
#[allow(dead_code)]
additional_data: T,
}
#[derive(Default)]
struct Phoneme {
#[allow(dead_code)]
first: String,
}
#[test]
fn skipped_field() {
let parsed: SpeakingOptions<Phoneme, Volume> = parse(
r#"
#[derive(Speak)]
#[speak(max_volume = "shout")]
enum HtmlElement {
Div(String)
}
"#,
);
assert_eq!(parsed.max_volume, Volume::Shout);
}