4 releases
Uses old Rust 2015
0.2.0 | Jun 9, 2018 |
---|---|
0.1.2 | Jun 5, 2018 |
0.1.1 | Jun 5, 2018 |
0.1.0 | Jun 4, 2018 |
#8 in #visit
23KB
588 lines
implement Trait Syn::Visit jquery style
Example
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]);
}
Dependencies
~2MB
~47K SLoC