syn_query

Crates.iosyn_query
lib.rssyn_query
version0.2.0
sourcesrc
created_at2018-06-04 13:48:02.767426
updated_at2018-06-09 15:44:07.088422
descriptionimplement Trait Syn::Visit
homepage
repositoryhttps://github.com/hjiayz/syn_query
max_upload_size
id68482
size65,943
ppc (hjiayz)

documentation

README

implement Trait Syn::Visit jquery style Build Status Latest Version Rust Documentation Rustc Version 1.15+

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]);
}
Commit count: 16

cargo fmt