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

#295 in Database implementations

Download history 6317/week @ 2024-10-09 6485/week @ 2024-10-16 5177/week @ 2024-10-23 5658/week @ 2024-10-30 4721/week @ 2024-11-06 4323/week @ 2024-11-13 4673/week @ 2024-11-20 4432/week @ 2024-11-27 4994/week @ 2024-12-04 5453/week @ 2024-12-11 4578/week @ 2024-12-18 3795/week @ 2024-12-25 4598/week @ 2025-01-01 4921/week @ 2025-01-08 5294/week @ 2025-01-15 5116/week @ 2025-01-22

20,500 downloads per month
Used in 8 crates (4 directly)

MIT license

24KB
559 lines

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.


lib.rs:

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);

Dependencies

~185–590KB
~14K SLoC