look_inside_derive

Crates.iolook_inside_derive
lib.rslook_inside_derive
version0.1.0
sourcesrc
created_at2024-01-02 16:13:52.76283
updated_at2024-01-02 16:13:52.76283
descriptionMacros for look_inside
homepagehttps://docs.rs/look_inside
repositoryhttps://github.com/CireSnave/look_inside
max_upload_size
id1086403
size4,624
CireSnave (ciresnave)

documentation

https://docs.rs/look_inside

README

look_inside

Did you ever wonder how Rust sees your data type?

Now you can find out with one simple derive macro...

But first, you need to add the look_inside crate to your dependencies in Cargo.toml:

[dependencies]
look_inside = "0.1"

Then you simply derive LookInside on struct struct, enum, or union and compile. LookInside will panic during compile and show you the full abstract syntax tree it breaks down into. Want to know the AST for a type other than a struct, enum, or union? No problem. Use your type in a struct, enum, or union.

Struct example:

use look_inside::LookInside;

#[Derive(LookInside)]
struct MyStruct {
    oneThing: u8,
    twoThing: String,
    threeThing: Vec<u16>,
}

Enum example:

use look_inside::LookInside;

#[Derive(LookInside)]
enum MyEnum {
    variantOne(u8),
    variantTwo(u16),
    variantThree(MyStruct)
}

Union example:

use look_inside::LookInside;

#[Derive(LookInside)]
union MyUnion {
    aU8: u8,
    aU16: u16,
    myStruct: MyStruct,
}

For those who want to understand how this all works...look at lib.rs. There is literally NOTHING to this.

If it's so simple, why did I make this crate? Simple, I wanted to see inside MY types so I can make better derive macros. Having this in a crate makes it easy to add it to any project I'm working on just long enough to inspect things and then remove it again.

Commit count: 0

cargo fmt