https://github.com/iddm/introspection
A rust introspection procedural macro.
https://github.com/iddm/introspection
introspection procedural-macros rust
Last synced: about 1 year ago
JSON representation
A rust introspection procedural macro.
- Host: GitHub
- URL: https://github.com/iddm/introspection
- Owner: iddm
- License: mit
- Created: 2017-03-02T08:54:43.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-05T18:54:57.000Z (over 2 years ago)
- Last Synced: 2024-11-14T14:46:08.433Z (over 1 year ago)
- Topics: introspection, procedural-macros, rust
- Language: Rust
- Size: 12.7 KB
- Stars: 18
- Watchers: 3
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# introspection
A rust introspection procedural macro.
[](https://crates.io/crates/introspection) [](https://travis-ci.org/iddm/introspection)
[](./LICENSE)
## What does it do?
It simply converts code from compile stage (from `syn` crate) to simplier structs. Works for `struct`s and `enum`s.
You may obtain this information through a [`Introspection`](https://github.com/iddm/introspection/blob/master/introspection/src/lib.rs) trait.
## Usage
1. Add `introspection` as dependency in your `Cargo.toml`:
```toml
[dependencies]
introspection-derive = "0.1"
introspection = "0.1"
```
2. Create a struct or enum:
```rust
#[macro_use]
extern crate introspection_derive;
extern crate introspection;
#[derive(Introspection)]
struct FrenchToast {
private_field: u64,
pub public_field: u8,
}
```
3. Use it:
```rust
fn main() {
use introspection::{ Introspection };
println!("Introspection: {:?}", FrenchToast::introspection());
}
```
4. See the results:
```
Running `target/debug/introspection-test`
Introspection: IntrospectionInfo { ident: "FrenchToast", visibility: Inherited, entity_type: Struct, fields: ["private_field", "public_field"] }
```
P.S. Personally I doubt this crate will help someone because it is impossible to do a lot of interesting and useful stuff from procedural macro at this moment unfortunately (rustc v1.15).
## License
This project is [licensed under the MIT license](https://github.com/iddm/introspection/blob/master/LICENSE).