1 unstable release
Uses old Rust 2015
0.1.0 | Mar 2, 2017 |
---|
#390 in #procedural
Used in introspection-derive
3KB
69 lines
introspection
A rust introspection procedural macro.
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
trait.
Usage
- Add
introspection
as dependency in yourCargo.toml
:
[dependencies]
introspection-derive = "0.1"
introspection = "0.1"
- Create a struct or enum:
#[macro_use]
extern crate introspection_derive;
extern crate introspection;
#[derive(Introspection)]
struct FrenchToast {
private_field: u64,
pub public_field: u8,
}
- Use it:
fn main() {
use introspection::{ Introspection };
println!("Introspection: {:?}", FrenchToast::introspection());
}
- 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.
Dependencies
~2MB
~50K SLoC