Skip to content

vityafx/introspection

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 

introspection

A rust introspection procedural macro.

MIT licensed

What does it do?

It simply converts code from compile stage (from syn crate) to simplier structs. Works for structs and enums. You may obtain this information through a Introspection trait.

Usage

  1. Add introspection as dependency in your Cargo.toml:
[dependencies]
introspection-derive = "0.1"
introspection = "0.1"
  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,
}
  1. Use it:
fn main() {
   use introspection::{ Introspection };
   println!("Introspection: {:?}", FrenchToast::introspection());
}
  1. 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.

About

A rust introspection procedural macro.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages