8 releases

0.3.0 May 22, 2023
0.2.1 Jun 16, 2022
0.2.0 Aug 23, 2019
0.1.4 Feb 11, 2019
0.1.2 Jan 30, 2019

#172 in Database implementations

Download history 17259/week @ 2025-08-07 16351/week @ 2025-08-14 13361/week @ 2025-08-21 16248/week @ 2025-08-28 15968/week @ 2025-09-04 14430/week @ 2025-09-11 14171/week @ 2025-09-18 14241/week @ 2025-09-25 17746/week @ 2025-10-02 14137/week @ 2025-10-09 13185/week @ 2025-10-16 11498/week @ 2025-10-23 13780/week @ 2025-10-30 13629/week @ 2025-11-06 18563/week @ 2025-11-13 12578/week @ 2025-11-20

60,286 downloads per month
Used in 9 crates (4 directly)

MIT license

24KB
559 lines

Library to get a specific element by path in Rust code.

Usage

let file: syn::File = syn::parse_str(
    r#"
    mod a {
        mod b {
            trait C {
                fn d(self) {}
                fn f() {}
            }
        }
    }"#).unwrap();
let results = syn_select::select("a::b::C::d", &file).unwrap();
assert_eq!(results.len(), 1);

syn-select

Build Status Latest Version Documentation

Lightweight path selector for searching Rust code.

mod a {
    mod b {
        trait C {
            fn d(self) {}

            fn f() {}
        }
    }
}

fn main() {
    let src_file = syn::parse_str(include_str!("./rs")).unwrap();

    // This will print out the trait `C`, limited to only function `d`.
    dbg!(syn_select::select("a::b::C::d", &src_file).unwrap());
}

Wildcards

Using _ as a path segment in a wildcard will match any element in that position. For example, in the following:

mod imp {
    struct H;
}

mod imp2 {
    struct H;
}

The selector _::H would match both structs named H.

Dependencies

~155–550KB
~13K SLoC