Debian Codegraph @

third_party/rust/darling/examples/expr_with.rs

raw
1 use darling::{util::parse_expr, FromDeriveInput};
2 use syn::{parse_quote, Expr};
3
4 #[derive(FromDeriveInput)]
5 #[darling(attributes(demo))]
6 pub struct Receiver {
7 #[darling(with = parse_expr::preserve_str_literal, map = Some)]
8 example1: Option<Expr>,
9 }
10
11 fn main() {
12 let input = Receiver::from_derive_input(&parse_quote! {
13 #[demo(example1 = test::path)]
14 struct Example;
15 })
16 .unwrap();
17
18 assert_eq!(input.example1, Some(parse_quote!(test::path)));
19 }