Crates.io | syn_query |
lib.rs | syn_query |
version | 0.2.0 |
source | src |
created_at | 2018-06-04 13:48:02.767426 |
updated_at | 2018-06-09 15:44:07.088422 |
description | implement Trait Syn::Visit |
homepage | |
repository | https://github.com/hjiayz/syn_query |
max_upload_size | |
id | 68482 |
size | 65,943 |
implement Trait Syn::Visit jquery style
extern crate proc_macro2;
extern crate syn;
extern crate syn_query;
use proc_macro2::Span;
use syn::{ExprStruct, FieldValue, Ident};
use syn_query::Queryable;
fn main() {
let s = "Point { x: 1, y: 1 }";
let st: ExprStruct = syn::parse_str(s).unwrap();
let qr = st.query::<Ident>();
assert_eq!(qr[0].data, Ident::new("Point", Span::call_site()));
assert_eq!(qr[0].path, vec![0i64, 0i64, 0i64]);
assert_eq!(qr[1].data, Ident::new("x", Span::call_site()));
assert_eq!(qr[1].path, vec![2i64, 0i64, 0i64]);
assert_eq!(qr[2].data, Ident::new("y", Span::call_site()));
assert_eq!(qr[2].path, vec![3i64, 0i64, 0i64]);
}