Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/TedDriggs/syn-select

Lightweight path selector for searching Rust code
https://github.com/TedDriggs/syn-select

rust

Last synced: 2 months ago
JSON representation

Lightweight path selector for searching Rust code

Awesome Lists containing this project

README

        

# syn-select

[![Build Status](https://travis-ci.org/TedDriggs/syn-select.svg?branch=master)](https://travis-ci.org/TedDriggs/syn-select)
[![Latest Version](https://img.shields.io/crates/v/syn-select.svg)](https://crates.io/crates/syn-select)
[![Documentation](https://docs.rs/syn-select/badge.svg)](https://docs.rs/syn-select)

Lightweight path selector for searching Rust code.

```rust
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:

```rust
mod imp {
struct H;
}

mod imp2 {
struct H;
}
```

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